diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-11-22 10:00:34 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-11-22 10:01:17 +0100 |
commit | 47fe7445e7f54aee10ec6dbc53f1db1adbeb43de (patch) | |
tree | 2d4e3e2ae0ceb4fda6eed32004379a98551f8a89 /src/script | |
parent | a2ed33b23bc0b4050aebd15dab5f78d9cda4d9d8 (diff) | |
parent | 4868c9f1b39f03adee0009cd41d96598b43e8b78 (diff) |
Merge bitcoin/bitcoin#22364: wallet: Make a tr() descriptor by default
4868c9f1b39f03adee0009cd41d96598b43e8b78 Extract Taproot internal keyid with GetKeyFromDestination (Andrew Chow)
d8abbe119c71f917e0fd2e80536c1e5d979b4dc6 Mention bech32m in -addresstype and -changetype help (Andrew Chow)
8fb57845ee3844c9ba854471065109d2e409300f Create a tr() descriptor bech32m DescriptorScriptPubKeyMan by default (Andrew Chow)
54b3699862de687f782c7c52500d6a2372478355 Store pubkeys in TRDescriptor::MakeScripts (Andrew Chow)
Pull request description:
Make a `tr()` descriptor by default in descriptor wallets so that users will be able to make and use segwit v1 bech32m addresses.
ACKs for top commit:
MarcoFalke:
Concept ACK 4868c9f1b39f03adee0009cd41d96598b43e8b78
Sjors:
re-utACK 4868c9f1b39f03adee0009cd41d96598b43e8b78
gruve-p:
ACK https://github.com/bitcoin/bitcoin/pull/22364/commits/4868c9f1b39f03adee0009cd41d96598b43e8b78
meshcollider:
Concept + code review ACK 4868c9f1b39f03adee0009cd41d96598b43e8b78
Tree-SHA512: e5896e665b8d559f1d759b6582d1bb24f70d4698a57307684339d9fdcdac28ae9bc17bc946a7efec9cb35c130a95ffc36e3961a335124ec4535d77b8d00e9631
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/descriptor.cpp | 1 | ||||
-rw-r--r-- | src/script/signingprovider.cpp | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 621a1b9fd6..c3b4d1ddaa 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -851,6 +851,7 @@ protected: builder.Finalize(xpk); WitnessV1Taproot output = builder.GetOutput(); out.tr_spenddata[output].Merge(builder.GetSpendData()); + out.pubkeys.emplace(keys[0].GetID(), keys[0]); return Vector(GetScriptForDestination(output)); } bool ToStringSubScriptHelper(const SigningProvider* arg, std::string& ret, const StringType type, const DescriptorCache* cache = nullptr) const override diff --git a/src/script/signingprovider.cpp b/src/script/signingprovider.cpp index b80fbe22ce..17f97fa30c 100644 --- a/src/script/signingprovider.cpp +++ b/src/script/signingprovider.cpp @@ -190,8 +190,8 @@ bool FillableSigningProvider::GetCScript(const CScriptID &hash, CScript& redeemS CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest) { - // Only supports destinations which map to single public keys, i.e. P2PKH, - // P2WPKH, and P2SH-P2WPKH. + // Only supports destinations which map to single public keys: + // P2PKH, P2WPKH, P2SH-P2WPKH, P2TR if (auto id = std::get_if<PKHash>(&dest)) { return ToKeyID(*id); } @@ -208,5 +208,15 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& } } } + if (auto output_key = std::get_if<WitnessV1Taproot>(&dest)) { + TaprootSpendData spenddata; + CPubKey pub; + if (store.GetTaprootSpendData(*output_key, spenddata) + && !spenddata.internal_key.IsNull() + && spenddata.merkle_root.IsNull() + && store.GetPubKeyByXOnly(spenddata.internal_key, pub)) { + return pub.GetID(); + } + } return CKeyID(); } |