Merge pull request #69 from ch4ot1c/fix/rawtransaction-forkid
[wallet] Add SIGHASH_FORKID where necessary
This commit is contained in:
commit
82b9ea1cb1
|
@ -633,7 +633,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
|
||||||
|
|
||||||
const CKeyStore& keystore = tempKeystore;
|
const CKeyStore& keystore = tempKeystore;
|
||||||
|
|
||||||
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
|
bool fHashSingle = ((nHashType & ~(SIGHASH_ANYONECANPAY|SIGHASH_FORKID)) == SIGHASH_SINGLE);
|
||||||
|
|
||||||
// Sign what we can:
|
// Sign what we can:
|
||||||
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
|
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
|
||||||
|
|
|
@ -62,12 +62,12 @@ std::string FormatScript(const CScript& script)
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<unsigned char, std::string> mapSigHashTypes = {
|
const std::map<unsigned char, std::string> mapSigHashTypes = {
|
||||||
{static_cast<unsigned char>(SIGHASH_ALL), std::string("ALL")},
|
{static_cast<unsigned char>(SIGHASH_ALL|SIGHASH_FORKID), std::string("ALL|FORKID")},
|
||||||
{static_cast<unsigned char>(SIGHASH_ALL|SIGHASH_ANYONECANPAY), std::string("ALL|ANYONECANPAY")},
|
{static_cast<unsigned char>(SIGHASH_ALL|SIGHASH_ANYONECANPAY|SIGHASH_FORKID), std::string("ALL|ANYONECANPAY|FORKID")},
|
||||||
{static_cast<unsigned char>(SIGHASH_NONE), std::string("NONE")},
|
{static_cast<unsigned char>(SIGHASH_NONE|SIGHASH_FORKID), std::string("NONE|FORKID")},
|
||||||
{static_cast<unsigned char>(SIGHASH_NONE|SIGHASH_ANYONECANPAY), std::string("NONE|ANYONECANPAY")},
|
{static_cast<unsigned char>(SIGHASH_NONE|SIGHASH_ANYONECANPAY|SIGHASH_FORKID), std::string("NONE|ANYONECANPAY|FORKID")},
|
||||||
{static_cast<unsigned char>(SIGHASH_SINGLE), std::string("SINGLE")},
|
{static_cast<unsigned char>(SIGHASH_SINGLE|SIGHASH_FORKID), std::string("SINGLE|FORKID")},
|
||||||
{static_cast<unsigned char>(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY), std::string("SINGLE|ANYONECANPAY")},
|
{static_cast<unsigned char>(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY|SIGHASH_FORKID), std::string("SINGLE|ANYONECANPAY|FORKID")},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -838,15 +838,15 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int nHashType = SIGHASH_ALL;
|
int nHashType = SIGHASH_ALL | SIGHASH_FORKID;
|
||||||
if (!hashType.isNull()) {
|
if (!hashType.isNull()) {
|
||||||
static std::map<std::string, int> mapSigHashValues = {
|
static std::map<std::string, int> mapSigHashValues = {
|
||||||
{std::string("ALL"), int(SIGHASH_ALL)},
|
{std::string("ALL|FORKID"), int(SIGHASH_ALL|SIGHASH_FORKID)},
|
||||||
{std::string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)},
|
{std::string("ALL|ANYONECANPAY|FORKID"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY|SIGHASH_FORKID)},
|
||||||
{std::string("NONE"), int(SIGHASH_NONE)},
|
{std::string("NONE|FORKID"), int(SIGHASH_NONE|SIGHASH_FORKID)},
|
||||||
{std::string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)},
|
{std::string("NONE|ANYONECANPAY|FORKID"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY|SIGHASH_FORKID)},
|
||||||
{std::string("SINGLE"), int(SIGHASH_SINGLE)},
|
{std::string("SINGLE|FORKID"), int(SIGHASH_SINGLE|SIGHASH_FORKID)},
|
||||||
{std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)},
|
{std::string("SINGLE|ANYONECANPAY|FORKID"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY|SIGHASH_FORKID)},
|
||||||
};
|
};
|
||||||
std::string strHashType = hashType.get_str();
|
std::string strHashType = hashType.get_str();
|
||||||
if (mapSigHashValues.count(strHashType)) {
|
if (mapSigHashValues.count(strHashType)) {
|
||||||
|
@ -856,7 +856,7 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE);
|
bool fHashSingle = ((nHashType & ~(SIGHASH_ANYONECANPAY|SIGHASH_FORKID)) == SIGHASH_SINGLE);
|
||||||
|
|
||||||
// Script verification errors
|
// Script verification errors
|
||||||
UniValue vErrors(UniValue::VARR);
|
UniValue vErrors(UniValue::VARR);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class MutableTransactionSignatureCreator : public BaseSignatureCreator {
|
||||||
const MutableTransactionSignatureChecker checker;
|
const MutableTransactionSignatureChecker checker;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MutableTransactionSignatureCreator(const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn = SIGHASH_ALL|SIGHASH_FORKID);
|
MutableTransactionSignatureCreator(const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn = SIGHASH_ALL | SIGHASH_FORKID);
|
||||||
const BaseSignatureChecker& Checker() const override { return checker; }
|
const BaseSignatureChecker& Checker() const override { return checker; }
|
||||||
bool CreateSig(const SigningProvider& provider, std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
|
bool CreateSig(const SigningProvider& provider, std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue