MCPcopy Create free account
hub / github.com/ElementsProject/elements / sign_multisig

Function sign_multisig

src/test/script_tests.cpp:1070–1093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1068}
1069
1070static CScript
1071sign_multisig(const CScript& scriptPubKey, const std::vector<CKey>& keys, const CTransaction& transaction)
1072{
1073 uint256 hash = SignatureHash(scriptPubKey, transaction, 0, SIGHASH_ALL, 0, SigVersion::BASE, 0);
1074
1075 CScript result;
1076 //
1077 // NOTE: CHECKMULTISIG has an unfortunate bug; it requires
1078 // one extra item on the stack, before the signatures.
1079 // Putting OP_0 on the stack is the workaround;
1080 // fixing the bug would mean splitting the block chain (old
1081 // clients would not accept new CHECKMULTISIG transactions,
1082 // and vice-versa)
1083 //
1084 result << OP_0;
1085 for (const CKey &key : keys)
1086 {
1087 std::vector<unsigned char> vchSig;
1088 BOOST_CHECK(key.Sign(hash, vchSig));
1089 vchSig.push_back((unsigned char)SIGHASH_ALL);
1090 result << vchSig;
1091 }
1092 return result;
1093}
1094static CScript
1095sign_multisig(const CScript& scriptPubKey, const CKey& key, const CTransaction& transaction)
1096{

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