MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / sign_multisig

Function sign_multisig

src/test/script_tests.cpp:1207–1230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1205}
1206
1207static CScript
1208sign_multisig(const CScript& scriptPubKey, const std::vector<CKey>& keys, const CTransaction& transaction)
1209{
1210 uint256 hash = SignatureHash(scriptPubKey, transaction, 0, SIGHASH_ALL | SIGHASH_FORKID, 0, SigVersion::BASE, false);
1211
1212 CScript result;
1213 //
1214 // NOTE: CHECKMULTISIG has an unfortunate bug; it requires
1215 // one extra item on the stack, before the signatures.
1216 // Putting OP_0 on the stack is the workaround;
1217 // fixing the bug would mean splitting the block chain (old
1218 // clients would not accept new CHECKMULTISIG transactions,
1219 // and vice-versa)
1220 //
1221 result << OP_0;
1222 for (const CKey &key : keys)
1223 {
1224 std::vector<unsigned char> vchSig;
1225 BOOST_CHECK(key.Sign(hash, vchSig));
1226 vchSig.push_back((unsigned char)(SIGHASH_ALL | SIGHASH_FORKID));
1227 result << vchSig;
1228 }
1229 return result;
1230}
1231static CScript
1232sign_multisig(const CScript& scriptPubKey, const CKey& key, const CTransaction& transaction)
1233{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.70

Calls 3

SignMethod · 0.80
SignatureHashFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected