mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #19836: rpc: Properly deserialize txs with witness before signing
33330778230961cfbf2a24de36b5877e395cc596 rpc: Adjust witness-tx deserialize error message (MarcoFalke) cccc7525697e7b8d99b545e34f0f504c78ffdb94 rpc: Properly deserialize txs with witness before signing (MarcoFalke) Pull request description: Signing a transaction can only happen when the transaction has inputs. A transaction with inputs can always be deserialized as witness-transaction. If `try_no_witness` decoding is attempted, this will lead to rare intermittent failures. Fixes #18803 ACKs for top commit: achow101: ACK 33330778230961cfbf2a24de36b5877e395cc596 ajtowns: ACK 33330778230961cfbf2a24de36b5877e395cc596 Tree-SHA512: 73f8a5cdfe03fb0e68908d2fa09752c346406f455694a020ec0dd1267ef8f0a583b8e84063ea74aac127106dd193b72623ca6d81469a94b3f5b3c766ebf2c42b
This commit is contained in:
parent
1bd4d8de71
commit
afb8f35b51
@ -352,7 +352,7 @@ static UniValue generateblock(const JSONRPCRequest& request)
|
|||||||
txs.push_back(MakeTransactionRef(std::move(mtx)));
|
txs.push_back(MakeTransactionRef(std::move(mtx)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("Transaction decode failed for %s", str));
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("Transaction decode failed for %s. Make sure the tx has at least one input.", str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
for (unsigned int idx = 0; idx < txs.size(); idx++) {
|
for (unsigned int idx = 0; idx < txs.size(); idx++) {
|
||||||
if (!DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
|
if (!DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d", idx));
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d. Make sure the tx has at least one input.", idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,7 +757,7 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
|
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
|
||||||
}
|
}
|
||||||
|
|
||||||
FillableSigningProvider keystore;
|
FillableSigningProvider keystore;
|
||||||
@ -823,10 +823,10 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
|||||||
UniValue::VBOOL
|
UniValue::VBOOL
|
||||||
});
|
});
|
||||||
|
|
||||||
// parse hex string from parameter
|
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
if (!DecodeHexTx(mtx, request.params[0].get_str()))
|
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
|
||||||
|
}
|
||||||
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
||||||
|
|
||||||
const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
|
const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
|
||||||
@ -898,7 +898,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
if (!DecodeHexTx(mtx, request.params[0].get_array()[0].get_str())) {
|
if (!DecodeHexTx(mtx, request.params[0].get_array()[0].get_str())) {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
|
||||||
}
|
}
|
||||||
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
|
||||||
const uint256& tx_hash = tx->GetHash();
|
const uint256& tx_hash = tx->GetHash();
|
||||||
|
@ -298,8 +298,9 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
|
|||||||
CWallet* const pwallet = wallet.get();
|
CWallet* const pwallet = wallet.get();
|
||||||
|
|
||||||
CMutableTransaction tx;
|
CMutableTransaction tx;
|
||||||
if (!DecodeHexTx(tx, request.params[0].get_str()))
|
if (!DecodeHexTx(tx, request.params[0].get_str())) {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
|
||||||
|
}
|
||||||
uint256 hashTx = tx.GetHash();
|
uint256 hashTx = tx.GetHash();
|
||||||
CWalletTx wtx(pwallet, MakeTransactionRef(std::move(tx)));
|
CWalletTx wtx(pwallet, MakeTransactionRef(std::move(tx)));
|
||||||
|
|
||||||
|
@ -3464,7 +3464,7 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
|
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign the transaction
|
// Sign the transaction
|
||||||
|
Loading…
Reference in New Issue
Block a user