diff options
author | Pieter Wuille <pieter@wuille.net> | 2022-01-10 18:12:14 -0500 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2022-01-12 11:09:41 -0500 |
commit | c17c6aa08df81aa0086d80b50187c8cd60ecc222 (patch) | |
tree | a4c4350d940192a6811dcc48dc4bb40644edeb22 /src/script/sign.cpp | |
parent | 3eed6fca57d1fa7544f372e6e7de0a9ae1b5715a (diff) | |
download | bitcoin-c17c6aa08df81aa0086d80b50187c8cd60ecc222.tar.xz |
Add signing support for (sorted)multi_a scripts
Diffstat (limited to 'src/script/sign.cpp')
-rw-r--r-- | src/script/sign.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 8e08448480..c6164e22d7 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -174,6 +174,29 @@ static bool SignTaprootScript(const SigningProvider& provider, const BaseSignatu result = Vector(std::move(sig)); return true; } + return false; + } + + // multi_a scripts (<key> OP_CHECKSIG <key> OP_CHECKSIGADD <key> OP_CHECKSIGADD <k> OP_NUMEQUAL) + if (auto match = MatchMultiA(script)) { + std::vector<std::vector<unsigned char>> sigs; + int good_sigs = 0; + for (size_t i = 0; i < match->second.size(); ++i) { + XOnlyPubKey pubkey{*(match->second.rbegin() + i)}; + std::vector<unsigned char> sig; + bool good_sig = CreateTaprootScriptSig(creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion); + if (good_sig && good_sigs < match->first) { + ++good_sigs; + sigs.push_back(std::move(sig)); + } else { + sigs.emplace_back(); + } + } + if (good_sigs == match->first) { + result = std::move(sigs); + return true; + } + return false; } return false; |