mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Add iswitness parameter to decode- and fundrawtransaction RPCs
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user