| 1029 | } |
| 1030 | |
| 1031 | static CScript |
| 1032 | sign_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 | } |
| 1055 | static CScript |
| 1056 | sign_multisig(const CScript& scriptPubKey, const CKey& key, const CTransaction& transaction) |
| 1057 | { |
no test coverage detected