diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -556,7 +556,7 @@ } static void MutateTxSign(CMutableTransaction &tx, const std::string &flagStr) { - SigHashType sigHashType = SigHashType().withForkId(true); + SigHashType sigHashType = SigHashType().withForkId(); if ((flagStr.size() > 0) && !findSigHashFlags(sigHashType, flagStr)) { throw std::runtime_error("unknown sighash flag/sign option"); @@ -674,7 +674,7 @@ SignatureData sigdata; // Only sign SIGHASH_SINGLE if there's a corresponding output: - if ((sigHashType.getBaseSigHashType() != BaseSigHashType::SINGLE) || + if ((sigHashType.getBaseType() != BaseSigHashType::SINGLE) || (i < mergedTx.vout.size())) { ProduceSignature(MutableTransactionSignatureCreator( &keystore, &mergedTx, i, amount, sigHashType), diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -991,7 +991,7 @@ const CKeyStore &keystore = tempKeystore; #endif - SigHashType sigHashType = SigHashType().withForkId(true); + SigHashType sigHashType = SigHashType().withForkId(); if (request.params.size() > 3 && !request.params[3].isNull()) { static std::map mapSigHashValues = { {"ALL", SIGHASH_ALL}, @@ -1042,7 +1042,7 @@ SignatureData sigdata; // Only sign SIGHASH_SINGLE if there's a corresponding output: - if ((sigHashType.getBaseSigHashType() != BaseSigHashType::SINGLE) || + if ((sigHashType.getBaseType() != BaseSigHashType::SINGLE) || (i < mergedTx.vout.size())) { ProduceSignature(MutableTransactionSignatureCreator( &keystore, &mergedTx, i, amount, sigHashType), diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -207,7 +207,7 @@ if (vchSig.size() == 0) { return false; } - if (!GetHashType(vchSig).hasSupportedBaseSigHashType()) { + if (!GetHashType(vchSig).hasSupportedBaseType()) { return false; } @@ -1264,8 +1264,8 @@ } // Serialize the nSequence if (nInput != nIn && - (sigHashType.getBaseSigHashType() == BaseSigHashType::SINGLE || - sigHashType.getBaseSigHashType() == BaseSigHashType::NONE)) { + (sigHashType.getBaseType() == BaseSigHashType::SINGLE || + sigHashType.getBaseType() == BaseSigHashType::NONE)) { // let the others update at will ::Serialize(s, (int)0); } else { @@ -1276,7 +1276,7 @@ /** Serialize an output of txTo */ template void SerializeOutput(S &s, unsigned int nOutput) const { - if (sigHashType.getBaseSigHashType() == BaseSigHashType::SINGLE && + if (sigHashType.getBaseType() == BaseSigHashType::SINGLE && nOutput != nIn) { // Do not lock-in the txout payee at other indices as txin ::Serialize(s, CTxOut()); @@ -1298,9 +1298,9 @@ } // Serialize vout unsigned int nOutputs = - (sigHashType.getBaseSigHashType() == BaseSigHashType::NONE) + (sigHashType.getBaseType() == BaseSigHashType::NONE) ? 0 - : ((sigHashType.getBaseSigHashType() == BaseSigHashType::SINGLE) + : ((sigHashType.getBaseType() == BaseSigHashType::SINGLE) ? nIn + 1 : txTo.vout.size()); ::WriteCompactSize(s, nOutputs); @@ -1359,16 +1359,15 @@ } if (!sigHashType.hasAnyoneCanPay() && - (sigHashType.getBaseSigHashType() != BaseSigHashType::SINGLE) && - (sigHashType.getBaseSigHashType() != BaseSigHashType::NONE)) { + (sigHashType.getBaseType() != BaseSigHashType::SINGLE) && + (sigHashType.getBaseType() != BaseSigHashType::NONE)) { hashSequence = cache ? cache->hashSequence : GetSequenceHash(txTo); } - if ((sigHashType.getBaseSigHashType() != BaseSigHashType::SINGLE) && - (sigHashType.getBaseSigHashType() != BaseSigHashType::NONE)) { + if ((sigHashType.getBaseType() != BaseSigHashType::SINGLE) && + (sigHashType.getBaseType() != BaseSigHashType::NONE)) { hashOutputs = cache ? cache->hashOutputs : GetOutputsHash(txTo); - } else if ((sigHashType.getBaseSigHashType() == - BaseSigHashType::SINGLE) && + } else if ((sigHashType.getBaseType() == BaseSigHashType::SINGLE) && (nIn < txTo.vout.size())) { CHashWriter ss(SER_GETHASH, 0); ss << txTo.vout[nIn]; @@ -1406,7 +1405,7 @@ } // Check for invalid use of SIGHASH_SINGLE - if ((sigHashType.getBaseSigHashType() == BaseSigHashType::SINGLE) && + if ((sigHashType.getBaseType() == BaseSigHashType::SINGLE) && (nIn >= txTo.vout.size())) { // nOut out of range return one; diff --git a/src/script/sighashtype.h b/src/script/sighashtype.h --- a/src/script/sighashtype.h +++ b/src/script/sighashtype.h @@ -43,36 +43,34 @@ explicit SigHashType(uint32_t sigHashIn) : sigHash(sigHashIn) {} - SigHashType withBaseSigHash(BaseSigHashType baseSigHashType) const { + SigHashType withBaseType(BaseSigHashType baseSigHashType) const { return SigHashType((sigHash & ~0x1f) | uint32_t(baseSigHashType)); } - SigHashType withForkId(bool forkId) const { + SigHashType withForkId(bool forkId = true) const { return SigHashType((sigHash & ~SIGHASH_FORKID) | (forkId ? SIGHASH_FORKID : 0)); } - SigHashType withAnyoneCanPay(bool anyoneCanPay) const { + SigHashType withAnyoneCanPay(bool anyoneCanPay = true) const { return SigHashType((sigHash & ~SIGHASH_ANYONECANPAY) | (anyoneCanPay ? SIGHASH_ANYONECANPAY : 0)); } - BaseSigHashType getBaseSigHashType() const { + BaseSigHashType getBaseType() const { return BaseSigHashType(sigHash & 0x1f); } - bool hasSupportedBaseSigHashType() const { - BaseSigHashType baseType = getBaseSigHashType(); + bool hasSupportedBaseType() const { + BaseSigHashType baseType = getBaseType(); return baseType >= BaseSigHashType::ALL && baseType <= BaseSigHashType::SINGLE; } - bool hasForkId() const { - return (sigHash & SIGHASH_FORKID) == SIGHASH_FORKID; - } + bool hasForkId() const { return (sigHash & SIGHASH_FORKID) != 0; } bool hasAnyoneCanPay() const { - return (sigHash & SIGHASH_ANYONECANPAY) == SIGHASH_ANYONECANPAY; + return (sigHash & SIGHASH_ANYONECANPAY) != 0; } uint32_t getRawSigHashType() const { return sigHash; } diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -353,7 +353,7 @@ for (int i = 0; i < 3; i++) { BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), txTo[i], 0, - SigHashType().withForkId(true)), + SigHashType().withForkId()), strprintf("SignSignature %d", i)); } } diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp --- a/src/test/script_P2SH_tests.cpp +++ b/src/test/script_P2SH_tests.cpp @@ -100,7 +100,7 @@ for (int i = 0; i < 8; i++) { BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), txTo[i], 0, - SigHashType().withForkId(true)), + SigHashType().withForkId()), strprintf("SignSignature %d", i)); } // All of the above should be OK, and the txTos have valid signatures @@ -208,7 +208,7 @@ for (int i = 0; i < 4; i++) { BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), txTo[i], 0, - SigHashType().withForkId(true)), + SigHashType().withForkId()), strprintf("SignSignature %d", i)); BOOST_CHECK_MESSAGE(IsStandardTx(CTransaction(txTo[i]), reason), strprintf("txTo[%d].IsStandard", i)); @@ -394,11 +394,11 @@ txTo.vin[i].prevout.hash = txFrom.GetId(); } BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 0, - SigHashType().withForkId(true))); + SigHashType().withForkId())); BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 1, - SigHashType().withForkId(true))); + SigHashType().withForkId())); BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 2, - SigHashType().withForkId(true))); + SigHashType().withForkId())); // SignSignature doesn't know how to sign these. We're not testing // validating signatures, so just create dummy signatures that DO include // the correct P2SH scripts: diff --git a/src/test/script_sighashtype_tests.cpp b/src/test/script_sighashtype_tests.cpp --- a/src/test/script_sighashtype_tests.cpp +++ b/src/test/script_sighashtype_tests.cpp @@ -7,141 +7,110 @@ #include +#include + BOOST_FIXTURE_TEST_SUITE(script_sighashtype_tests, BasicTestingSetup) -BOOST_AUTO_TEST_CASE(SigHashTypeTests) { - BOOST_CHECK(SigHashType().getBaseSigHashType() == BaseSigHashType::ALL); - - BOOST_CHECK(SigHashType(SIGHASH_ALL).getBaseSigHashType() == - BaseSigHashType::ALL); - - BOOST_CHECK(SigHashType(SIGHASH_NONE).getBaseSigHashType() == - BaseSigHashType::NONE); - - BOOST_CHECK(SigHashType(SIGHASH_SINGLE).getBaseSigHashType() == - BaseSigHashType::SINGLE); - - BOOST_CHECK_EQUAL(SigHashType().hasSupportedBaseSigHashType(), true); - BOOST_CHECK_EQUAL(SigHashType(0).hasSupportedBaseSigHashType(), false); - BOOST_CHECK_EQUAL(SigHashType(SIGHASH_ALL).hasSupportedBaseSigHashType(), - true); - BOOST_CHECK_EQUAL(SigHashType(SIGHASH_NONE).hasSupportedBaseSigHashType(), - true); - BOOST_CHECK_EQUAL(SigHashType(SIGHASH_SINGLE).hasSupportedBaseSigHashType(), - true); - BOOST_CHECK_EQUAL(SigHashType(4).hasSupportedBaseSigHashType(), false); - - BOOST_CHECK_EQUAL(SigHashType(SIGHASH_ALL | SIGHASH_FORKID).hasForkId(), - true); - BOOST_CHECK_EQUAL( - SigHashType(SIGHASH_ALL | SIGHASH_FORKID).hasAnyoneCanPay(), false); - - BOOST_CHECK_EQUAL( - SigHashType(SIGHASH_ALL | SIGHASH_ANYONECANPAY).hasForkId(), false); - BOOST_CHECK_EQUAL( - SigHashType(SIGHASH_ALL | SIGHASH_ANYONECANPAY).hasAnyoneCanPay(), - true); - - BOOST_CHECK(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .getBaseSigHashType() == BaseSigHashType::ALL); - BOOST_CHECK(SigHashType() - .withBaseSigHash(BaseSigHashType::NONE) - .getBaseSigHashType() == BaseSigHashType::NONE); - BOOST_CHECK(SigHashType() - .withBaseSigHash(BaseSigHashType::SINGLE) - .getBaseSigHashType() == BaseSigHashType::SINGLE); - BOOST_CHECK_EQUAL(SigHashType().withForkId(true).hasForkId(), true); - BOOST_CHECK_EQUAL(SigHashType().withAnyoneCanPay(true).hasAnyoneCanPay(), - true); - - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withForkId(true) - .getRawSigHashType(), - SIGHASH_ALL | SIGHASH_FORKID); - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::NONE) - .withForkId(true) - .getRawSigHashType(), - SIGHASH_NONE | SIGHASH_FORKID); - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::SINGLE) - .withForkId(true) - .getRawSigHashType(), - SIGHASH_SINGLE | SIGHASH_FORKID); - - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withAnyoneCanPay(true) - .getRawSigHashType(), - SIGHASH_ALL | SIGHASH_ANYONECANPAY); - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::NONE) - .withAnyoneCanPay(true) - .getRawSigHashType(), - SIGHASH_NONE | SIGHASH_ANYONECANPAY); - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::SINGLE) - .withAnyoneCanPay(true) - .getRawSigHashType(), - SIGHASH_SINGLE | SIGHASH_ANYONECANPAY); - - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withAnyoneCanPay(true) - .withForkId(true) - .getRawSigHashType(), - SIGHASH_ALL | SIGHASH_ANYONECANPAY | SIGHASH_FORKID); - - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withForkId(true) - .withForkId(false) - .hasForkId(), - false); - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withForkId(false) - .withForkId(true) - .hasForkId(), - true); - - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withAnyoneCanPay(true) - .withAnyoneCanPay(false) - .hasAnyoneCanPay(), - false); - BOOST_CHECK_EQUAL(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withAnyoneCanPay(false) - .withAnyoneCanPay(true) - .hasAnyoneCanPay(), - true); - - BOOST_CHECK(SigHashType() - .withBaseSigHash(BaseSigHashType::ALL) - .withAnyoneCanPay(true) - .withForkId(true) - .withBaseSigHash(BaseSigHashType::NONE) - .getBaseSigHashType() == BaseSigHashType::NONE); - - uint32_t unserializedOutput; - for (int baseSigHash = 0; baseSigHash <= 0x1f; - baseSigHash++) { // Test all possible base sig hash values - (CDataStream(SER_DISK, 0) << SigHashType(baseSigHash)) >> - unserializedOutput; - BOOST_CHECK_EQUAL(unserializedOutput, baseSigHash); - (CDataStream(SER_DISK, 0) - << SigHashType(baseSigHash).withForkId(true)) >> - unserializedOutput; - BOOST_CHECK_EQUAL(unserializedOutput, baseSigHash | SIGHASH_FORKID); - (CDataStream(SER_DISK, 0) - << SigHashType(baseSigHash).withAnyoneCanPay(true)) >> - unserializedOutput; +static void CheckSigHashType(SigHashType t, BaseSigHashType baseType, + bool hasSupportedBaseType, bool hasForkId, + bool hasAnyoneCanPay) { + BOOST_CHECK(t.getBaseType() == baseType); + BOOST_CHECK_EQUAL(t.hasSupportedBaseType(), hasSupportedBaseType); + BOOST_CHECK_EQUAL(t.hasForkId(), hasForkId); + BOOST_CHECK_EQUAL(t.hasAnyoneCanPay(), hasAnyoneCanPay); +} + +BOOST_AUTO_TEST_CASE(sighash_construction_test) { + // Check default values. + CheckSigHashType(SigHashType(), BaseSigHashType::ALL, true, false, false); + + // Check all possible permutations. + std::set baseTypes{ + BaseSigHashType::UNSUPPORTED, BaseSigHashType::ALL, + BaseSigHashType::NONE, BaseSigHashType::SINGLE}; + std::set forkIdFlagValues{false, true}; + std::set anyoneCanPayFlagValues{false, true}; + + for (BaseSigHashType baseType : baseTypes) { + for (bool hasForkId : forkIdFlagValues) { + for (bool hasAnyoneCanPay : anyoneCanPayFlagValues) { + SigHashType t = SigHashType() + .withBaseType(baseType) + .withForkId(hasForkId) + .withAnyoneCanPay(hasAnyoneCanPay); + + bool hasSupportedBaseType = + baseType != BaseSigHashType::UNSUPPORTED; + CheckSigHashType(t, baseType, hasSupportedBaseType, hasForkId, + hasAnyoneCanPay); + + // Also check all possible alterations. + CheckSigHashType(t.withForkId(hasForkId), baseType, + hasSupportedBaseType, hasForkId, + hasAnyoneCanPay); + CheckSigHashType(t.withForkId(!hasForkId), baseType, + hasSupportedBaseType, !hasForkId, + hasAnyoneCanPay); + CheckSigHashType(t.withAnyoneCanPay(hasAnyoneCanPay), baseType, + hasSupportedBaseType, hasForkId, + hasAnyoneCanPay); + CheckSigHashType(t.withAnyoneCanPay(!hasAnyoneCanPay), baseType, + hasSupportedBaseType, hasForkId, + !hasAnyoneCanPay); + + for (BaseSigHashType newBaseType : baseTypes) { + bool hasSupportedNewBaseType = + newBaseType != BaseSigHashType::UNSUPPORTED; + CheckSigHashType(t.withBaseType(newBaseType), newBaseType, + hasSupportedNewBaseType, hasForkId, + hasAnyoneCanPay); + } + } + } + } +} + +BOOST_AUTO_TEST_CASE(sighash_serialization_test) { + // Test all possible base sig hash values + for (uint32_t baseType = 0; baseType <= 0x1f; baseType++) { + bool hasSupportedBaseType = + (baseType != 0) && (baseType <= SIGHASH_SINGLE); + + SigHashType tbase(baseType); + SigHashType tforkid(baseType | SIGHASH_FORKID); + SigHashType tanyonecanspend(baseType | SIGHASH_ANYONECANPAY); + SigHashType tboth(baseType | SIGHASH_FORKID | SIGHASH_ANYONECANPAY); + + // Check deserialization. + CheckSigHashType(tbase, BaseSigHashType(baseType), hasSupportedBaseType, + false, false); + CheckSigHashType(tforkid, BaseSigHashType(baseType), + hasSupportedBaseType, true, false); + CheckSigHashType(tanyonecanspend, BaseSigHashType(baseType), + hasSupportedBaseType, false, true); + CheckSigHashType(tboth, BaseSigHashType(baseType), hasSupportedBaseType, + true, true); + + // Check raw value. + BOOST_CHECK_EQUAL(tbase.getRawSigHashType(), baseType); + BOOST_CHECK_EQUAL(tforkid.getRawSigHashType(), + baseType | SIGHASH_FORKID); + BOOST_CHECK_EQUAL(tanyonecanspend.getRawSigHashType(), + baseType | SIGHASH_ANYONECANPAY); + BOOST_CHECK_EQUAL(tboth.getRawSigHashType(), + baseType | SIGHASH_FORKID | SIGHASH_ANYONECANPAY); + + // Check serialization/deserialization. + uint32_t unserializedOutput; + (CDataStream(SER_DISK, 0) << tbase) >> unserializedOutput; + BOOST_CHECK_EQUAL(unserializedOutput, baseType); + (CDataStream(SER_DISK, 0) << tforkid) >> unserializedOutput; + BOOST_CHECK_EQUAL(unserializedOutput, baseType | SIGHASH_FORKID); + (CDataStream(SER_DISK, 0) << tanyonecanspend) >> unserializedOutput; + BOOST_CHECK_EQUAL(unserializedOutput, baseType | SIGHASH_ANYONECANPAY); + (CDataStream(SER_DISK, 0) << tboth) >> unserializedOutput; BOOST_CHECK_EQUAL(unserializedOutput, - baseSigHash | SIGHASH_ANYONECANPAY); + baseType | SIGHASH_FORKID | SIGHASH_ANYONECANPAY); } } diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -447,11 +447,11 @@ tests.push_back( TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, "P2PK anyonecanpay", 0) - .PushSig(keys.key1, SigHashType().withAnyoneCanPay(true))); + .PushSig(keys.key1, SigHashType().withAnyoneCanPay())); tests.push_back( TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, "P2PK anyonecanpay marked with normal hashtype", 0) - .PushSig(keys.key1, SigHashType().withAnyoneCanPay(true)) + .PushSig(keys.key1, SigHashType().withAnyoneCanPay()) .EditPush(70, "81", "01") .ScriptError(SCRIPT_ERR_EVAL_FALSE)); @@ -1021,22 +1021,21 @@ TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, "P2PK FORKID", SCRIPT_ENABLE_SIGHASH_FORKID, false, TEST_AMOUNT) - .PushSig(keys.key0, SigHashType().withForkId(true), 32, 32, + .PushSig(keys.key0, SigHashType().withForkId(), 32, 32, TEST_AMOUNT)); tests.push_back( TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, "P2PK INVALID AMOUNT", SCRIPT_ENABLE_SIGHASH_FORKID, false, TEST_AMOUNT) - .PushSig(keys.key0, SigHashType().withForkId(true), 32, 32, + .PushSig(keys.key0, SigHashType().withForkId(), 32, 32, TEST_AMOUNT + Amount(1)) .ScriptError(SCRIPT_ERR_EVAL_FALSE)); tests.push_back( TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, "P2PK INVALID FORKID", SCRIPT_VERIFY_STRICTENC, false, TEST_AMOUNT) - .PushSig(keys.key0, SigHashType().withForkId(true), 32, 32, - TEST_AMOUNT) + .PushSig(keys.key0, SigHashType().withForkId(), 32, 32, TEST_AMOUNT) .ScriptError(SCRIPT_ERR_ILLEGAL_FORKID)); std::set tests_set; @@ -1453,13 +1452,13 @@ std::vector sig2; uint256 hash2 = SignatureHash( scriptPubKey, CTransaction(txTo), 0, - SigHashType().withBaseSigHash(BaseSigHashType::NONE), Amount(0)); + SigHashType().withBaseType(BaseSigHashType::NONE), Amount(0)); BOOST_CHECK(keys[1].Sign(hash2, sig2)); sig2.push_back(SIGHASH_NONE); std::vector sig3; uint256 hash3 = SignatureHash( scriptPubKey, CTransaction(txTo), 0, - SigHashType().withBaseSigHash(BaseSigHashType::SINGLE), Amount(0)); + SigHashType().withBaseType(BaseSigHashType::SINGLE), Amount(0)); BOOST_CHECK(keys[2].Sign(hash3, sig3)); sig3.push_back(SIGHASH_SINGLE); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -348,8 +348,8 @@ inputm.vout.resize(1); inputm.vout[0].nValue = Amount(1); inputm.vout[0].scriptPubKey = CScript(); - bool ret = SignSignature(keystore, *output, inputm, 0, - SigHashType().withForkId(true)); + bool ret = + SignSignature(keystore, *output, inputm, 0, SigHashType().withForkId()); BOOST_CHECK_EQUAL(ret, success); CDataStream ssin(SER_NETWORK, PROTOCOL_VERSION); ssin << inputm; diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp --- a/src/test/txvalidationcache_tests.cpp +++ b/src/test/txvalidationcache_tests.cpp @@ -54,7 +54,7 @@ // Sign: std::vector vchSig; uint256 hash = SignatureHash(scriptPubKey, CTransaction(spends[i]), 0, - SigHashType().withForkId(true), + SigHashType().withForkId(), coinbaseTxns[0].vout[0].nValue); BOOST_CHECK(coinbaseKey.Sign(hash, vchSig)); vchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); @@ -194,7 +194,7 @@ std::vector vchSig; uint256 hash = SignatureHash( p2pk_scriptPubKey, CTransaction(mutableSpend_tx), 0, - SigHashType().withForkId(true), coinbaseTxns[0].vout[0].nValue); + SigHashType().withForkId(), coinbaseTxns[0].vout[0].nValue); BOOST_CHECK(coinbaseKey.Sign(hash, vchSig)); vchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); mutableSpend_tx.vin[0].scriptSig << OP_TRUE << vchSig; @@ -278,7 +278,7 @@ std::vector vchSig; uint256 hash = SignatureHash( spend_tx.vout[1].scriptPubKey, CTransaction(invalid_with_cltv_tx), - 0, SigHashType().withForkId(true), spend_tx.vout[1].nValue); + 0, SigHashType().withForkId(), spend_tx.vout[1].nValue); BOOST_CHECK(coinbaseKey.Sign(hash, vchSig)); vchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); invalid_with_cltv_tx.vin[0].scriptSig = CScript() << vchSig << 101; @@ -316,7 +316,7 @@ std::vector vchSig; uint256 hash = SignatureHash( spend_tx.vout[2].scriptPubKey, CTransaction(invalid_with_csv_tx), 0, - SigHashType().withForkId(true), spend_tx.vout[2].nValue); + SigHashType().withForkId(), spend_tx.vout[2].nValue); BOOST_CHECK(coinbaseKey.Sign(hash, vchSig)); vchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); invalid_with_csv_tx.vin[0].scriptSig = CScript() << vchSig << 101; @@ -357,12 +357,12 @@ SignatureData sigdata; ProduceSignature( MutableTransactionSignatureCreator(&keystore, &tx, 0, 11 * CENT, - SigHashType().withForkId(true)), + SigHashType().withForkId()), spend_tx.vout[0].scriptPubKey, sigdata); UpdateTransaction(tx, 0, sigdata); ProduceSignature( MutableTransactionSignatureCreator(&keystore, &tx, 1, 11 * CENT, - SigHashType().withForkId(true)), + SigHashType().withForkId()), spend_tx.vout[3].scriptPubKey, sigdata); UpdateTransaction(tx, 1, sigdata); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3008,7 +3008,7 @@ } if (sign) { - SigHashType sigHashType = SigHashType().withForkId(true); + SigHashType sigHashType = SigHashType().withForkId(); CTransaction txNewConst(txNew); int nIn = 0;