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

Function sign_multisig

src/test/script_tests.cpp:1031–1054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1029}
1030
1031static CScript
1032sign_multisig(const CScript& scriptPubKey, const std::vector<CKey>& keys, const CTransaction& transaction)
1033{
1034 uint256 hash = SignatureHash(scriptPubKey, transaction, 0, SIGHASH_ALL, 0, SigVersion::BASE);
1035
1036 CScript result;
1037 //
1038 // NOTE: CHECKMULTISIG has an unfortunate bug; it requires
1039 // one extra item on the stack, before the signatures.
1040 // Putting OP_0 on the stack is the workaround;
1041 // fixing the bug would mean splitting the block chain (old
1042 // clients would not accept new CHECKMULTISIG transactions,
1043 // and vice-versa)
1044 //
1045 result << OP_0;
1046 for (const CKey &key : keys)
1047 {
1048 std::vector<unsigned char> vchSig;
1049 BOOST_CHECK(key.Sign(hash, vchSig));
1050 vchSig.push_back((unsigned char)SIGHASH_ALL);
1051 result << vchSig;
1052 }
1053 return result;
1054}
1055static CScript
1056sign_multisig(const CScript& scriptPubKey, const CKey& key, const CTransaction& transaction)
1057{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.70

Calls 3

SignatureHashFunction · 0.85
SignMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected