Taproot testnet wallet

Taproot testnet wallet
2021-10-09 16:49 ` Pieter Wuille
  
From: Andreas Schildbach @ 2021-10-09 15:36 UTC (permalink / raw)
  To: bitcoin-dev

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!


 permalink raw reply	[|nested]
2021-10-09 15:36 [bitcoin-dev] Taproot testnet wallet Andreas Schildbach

  2021-10-15  1:05   ` Anthony Towns
  
From: Pieter Wuille @ 2021-10-09 16:49 UTC (permalink / raw)
  To: andreas, bitcoin-dev

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

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

> 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.)

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,

--

Pieter

[-- Attachment #2: Type: text/html, Size: 1578 bytes --]

 permalink raw reply	[|nested]
2021-10-09 16:49 ` Pieter Wuille

  2021-10-15 11:51     ` vjudeu
  
From: Anthony Towns @ 2021-10-15  1:05 UTC (permalink / raw)
  To: Pieter Wuille, Bitcoin Protocol Discussion

On Sat, Oct 09, 2021 at 04:49:42PM +0000, Pieter Wuille via bitcoin-dev wrote:
> 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



 permalink raw reply	[|nested]
2021-10-15  1:05   ` Anthony Towns

  
From: vjudeu @ 2021-10-15 11:51 UTC ( / )
  To: Anthony Towns, Pieter Wuille, Bitcoin Protocol Discussion

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

> 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.
From: Prayank @ 2021-10-15 14:12 UTC (permalink / raw)
  To: andreas;  Bitcoin Dev

[-- Attachment #1: Type: text/plain, Size: 939 bytes --]

Hi Andreas,

> 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.

-- 
Prayank

A3B1 E430 2298 178F

[-- Attachment #2: Type: text/html, Size: 1686 bytes --]

 permalink raw reply	[|nested]