Add iswitness parameter to decode- and fundrawtransaction RPCs

This commit is contained in:
MeshCollider
2017-08-28 18:00:21 +12:00
parent 28485c783d
commit bbdbe805a2
6 changed files with 45 additions and 29 deletions

View File

@@ -108,39 +108,39 @@ bool CheckTxScriptsSanity(const CMutableTransaction& tx)
return true;
}
bool DecodeHexTx(CMutableTransaction& tx, const std::string& strHexTx, bool fTryNoWitness)
bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness, bool try_witness)
{
if (!IsHex(strHexTx)) {
if (!IsHex(hex_tx)) {
return false;
}
std::vector<unsigned char> txData(ParseHex(strHexTx));
std::vector<unsigned char> txData(ParseHex(hex_tx));
if (fTryNoWitness) {
if (try_no_witness) {
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
try {
ssData >> tx;
if (ssData.eof() && CheckTxScriptsSanity(tx)) {
if (ssData.eof() && (!try_witness || CheckTxScriptsSanity(tx))) {
return true;
}
}
catch (const std::exception&) {
} catch (const std::exception&) {
// Fall through.
}
}
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
try {
ssData >> tx;
if (!ssData.empty()) {
return false;
if (try_witness) {
CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION);
try {
ssData >> tx;
if (ssData.empty()) {
return true;
}
} catch (const std::exception&) {
// Fall through.
}
}
catch (const std::exception&) {
return false;
}
return true;
return false;
}
bool DecodeHexBlk(CBlock& block, const std::string& strHexBlk)