LearnBitcoin

Bitcoin Dev Archive 2021

Taproot testnet wallet

5 messages, 9 to 15 Oct 2021. Started by Andreas Schildbach.

Andreas Schildbach, Pieter Wuille, Anthony Towns, vjudeu, Prayank

Permalink Original thread on gnusha.org

Andreas Schildbach permalink original

I'm trying to finish off bitcoinj's implementation for sending to taproot addresses. For this, I'd like to test against a wallet that can receive to P2TR and spend back.

I've been trying to get a taproot address from Bitcoin Core 22.0 and spent many hours, but in vain. Can someone please simply send my a testnet wallet that has at least one taproot address? (I don't care about anyone stealing my testnet coins, so don't worry about the compromised private key.)

Thanks!

Pieter Wuille in reply to Andreas Schildbach permalink original

On Oct 9, 2021, 11:36, Andreas Schildbach via bitcoin-dev < bitcoin-dev@lists•linuxfoundation•org> wrote:

Quoted text (1 line)
> I'm trying to finish off bitcoinj's implementation for sending to

taproot addresses. For this, I'd like to test against a wallet that can

receive to P2TR and spend back.

Quoted text (1 line)
> I've been trying to get a taproot address from Bitcoin Core 22.0 and

spent many hours, but in vain. Can someone please simply send my a

testnet wallet that has at least one taproot address? (I don't care

about anyone stealing my testnet coins, so don't worry about the

compromised private key.)

Hi Andreas,

You can construct a taproot-capable wallet in Bitcoin Core as follows:

* Have or create a descriptor wallet (createwallet RPC, with descriptors=true).
* Import a taproot descriptor (of the form "tr(KEY)"), as active descriptor (with active=true), where KEY can be a tprv.../* or any other supported key expression.
* Get a new address with addresstype=bech32m

I've also created one myself for testing: tb1p84x2ryuyfevgnlpnxt9f39gm7r68gwtvllxqe5w2n5ru00s9aquslzggwq

If you send testnet coins there email me an address, I'll return them.

Cheers,

Anthony Towns in reply to Pieter Wuille permalink original

On Sat, Oct 09, 2021 at 04:49:42PM +0000, Pieter Wuille via bitcoin-dev wrote:

Quoted text (6 lines)
> You can construct a taproot-capable wallet in Bitcoin Core as follows:
> * Have or create a descriptor wallet (createwallet RPC, with descriptors=true).
> * Import a taproot descriptor (of the form "tr(KEY)"), as active descriptor
> (with active=true), where KEY can be a tprv.../* or any other supported key
> expression.
> * Get a new address with addresstype=bech32m

Running master (which has PR#21500 merged), then the above can be done with:

1. create a descriptor wallet
  bitcoin-cli -signet -named createwallet wallet_name=descwallet descriptors=true load_on_startup=true
2. get the associated bip32 tprv private key
  TPRV=$(bitcoin-cli -rpcwallet=descwallet -signet listdescriptors true | jq '.descriptors | .[].desc' | sed 's/^.*(//;s/[)/].*//' | uniq | head -n1)

(This step requires PR#21500 to extract the wallet's tprv; you'll need to be running an updated version of bitcoin-cli here as well as bitcoind. You could also generate the tprv some other way.)

3. construct the taproot descriptor per BIP 86
  DESC="tr($TPRV/86'/1'/0'/0/*)"
  CHK="$(bitcoin-cli -rpcwallet=descwallet -signet getdescriptorinfo "$DESC" | jq -r .checksum)"
4. import the descriptor
  bitcoin-cli -rpcwallet=descwallet -signet importdescriptors "[{\"desc\": \"$DESC#$CHK\", \"active\": true, \"timestamp\": \"now\", \"range\": [0,1000], \"next_index\": 1}]"
5. get an address
  bitcoin-cli -rpcwallet=descwallet -signet getnewaddress '' bech32m

You can then use the signet faucet to send a few million ssats to that address directly.

Same stuff works with testnet, though I'm not sure if any testnet faucets will accept bech32m addresses directly.

This is all a bit deliberately cumbersome prior to taproot activating on mainnet; once that happens and PR#22364 is merged, you'll only need to do steps (1) and (5).

Cheers, aj

vjudeu in reply to Anthony Towns permalink original

On 2021-10-15 03:05:36 user Anthony Towns via bitcoin-dev <bitcoin-dev@lists•linuxfoundation•org> wrote:

Quoted text (1 line)
> Same stuff works with testnet, though I'm not sure if any testnet faucets

will accept bech32m addresses directly.

There are faucets that accept such addresses, for example https://bitcoinfaucet.uo1.net/, but you have to use bech32 checksum instead of bech32m, for example sending to tb1p84x2ryuyfevgnlpnxt9f39gm7r68gwtvllxqe5w2n5ru00s9aqus27cytz works fine, but sending to tb1p84x2ryuyfevgnlpnxt9f39gm7r68gwtvllxqe5w2n5ru00s9aquslzggwq does not work. The same with pages like mempool.space, you have to use bech32 instead of bech32m, then you can send to taproot from some old faucets or browse taproot addresses from some old block explorers.

Prayank in reply to Andreas Schildbach permalink original

Hi Andreas,

Quoted text (1 line)
> I'm trying to finish off bitcoinj's implementation for sending to

taproot addresses. For this, I'd like to test against a wallet that can receive to P2TR and spend back.

I did this transaction few days back which creates a P2TR output while answering a question on Bitcoin Stackexchange: https://blockstream.info/testnet/tx/2035ead4a9d0c8e2da1184924abc9034d26f2a7093371183ef12891623b235d1

Pieter Wuille and Anthony Towns already shared things that would be helpful. Still wanted to share the steps I did for above transaction:

https://bitcoin.stackexchange.com/a/108013/

TL;DR -

1.Create a blank descriptor wallet with private keys disabled

2.Import TPUB descriptor in wallet

3.Create new bech32m address

4.Send some bitcoin from another wallet

The answer could be improved if test vectors are added in BIP 86 for TPRV for follow things suggested by Anthony Towns in last email.