Skip to content

Commit c17c6aa

Browse files
committed
Add signing support for (sorted)multi_a scripts
1 parent 3eed6fc commit c17c6aa

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/script/sign.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,29 @@ static bool SignTaprootScript(const SigningProvider& provider, const BaseSignatu
174174
result = Vector(std::move(sig));
175175
return true;
176176
}
177+
return false;
178+
}
179+
180+
// multi_a scripts (<key> OP_CHECKSIG <key> OP_CHECKSIGADD <key> OP_CHECKSIGADD <k> OP_NUMEQUAL)
181+
if (auto match = MatchMultiA(script)) {
182+
std::vector<std::vector<unsigned char>> sigs;
183+
int good_sigs = 0;
184+
for (size_t i = 0; i < match->second.size(); ++i) {
185+
XOnlyPubKey pubkey{*(match->second.rbegin() + i)};
186+
std::vector<unsigned char> sig;
187+
bool good_sig = CreateTaprootScriptSig(creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion);
188+
if (good_sig && good_sigs < match->first) {
189+
++good_sigs;
190+
sigs.push_back(std::move(sig));
191+
} else {
192+
sigs.emplace_back();
193+
}
194+
}
195+
if (good_sigs == match->first) {
196+
result = std::move(sigs);
197+
return true;
198+
}
199+
return false;
177200
}
178201

179202
return false;

0 commit comments

Comments
 (0)