Skip to content

Commit 3333077

Browse files
author
MarcoFalke
committed
rpc: Adjust witness-tx deserialize error message
1 parent cccc752 commit 3333077

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/rpc/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static UniValue generateblock(const JSONRPCRequest& request)
346346
txs.push_back(MakeTransactionRef(std::move(mtx)));
347347

348348
} else {
349-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("Transaction decode failed for %s", str));
349+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("Transaction decode failed for %s. Make sure the tx has at least one input.", str));
350350
}
351351
}
352352

src/rpc/rawtransaction.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request)
645645

646646
for (unsigned int idx = 0; idx < txs.size(); idx++) {
647647
if (!DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
648-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d", idx));
648+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d. Make sure the tx has at least one input.", idx));
649649
}
650650
}
651651

@@ -767,7 +767,7 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
767767

768768
CMutableTransaction mtx;
769769
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
770-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
770+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
771771
}
772772

773773
FillableSigningProvider keystore;
@@ -831,10 +831,10 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
831831
UniValueType(), // VNUM or VSTR, checked inside AmountFromValue()
832832
});
833833

834-
// parse hex string from parameter
835834
CMutableTransaction mtx;
836-
if (!DecodeHexTx(mtx, request.params[0].get_str()))
837-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
835+
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
836+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
837+
}
838838
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
839839

840840
const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
@@ -905,7 +905,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
905905

906906
CMutableTransaction mtx;
907907
if (!DecodeHexTx(mtx, request.params[0].get_array()[0].get_str())) {
908-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
908+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
909909
}
910910
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
911911
const uint256& tx_hash = tx->GetHash();

src/wallet/rpcdump.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
334334
CWallet* const pwallet = wallet.get();
335335

336336
CMutableTransaction tx;
337-
if (!DecodeHexTx(tx, request.params[0].get_str()))
338-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
337+
if (!DecodeHexTx(tx, request.params[0].get_str())) {
338+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
339+
}
339340
uint256 hashTx = tx.GetHash();
340341

341342
CDataStream ssMB(ParseHexV(request.params[1], "proof"), SER_NETWORK, PROTOCOL_VERSION);

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3230,7 +3230,7 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
32303230

32313231
CMutableTransaction mtx;
32323232
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
3233-
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
3233+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
32343234
}
32353235

32363236
// Sign the transaction

0 commit comments

Comments
 (0)