aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2020-09-19 14:34:52 +0800
committerfanquake <fanquake@gmail.com>2020-09-19 15:04:03 +0800
commitc30f79d418e2e001f1f804a2370db47e5d9ea587 (patch)
tree5073f9436079ebba8b60f01c3891a6c18cacb368 /src/rpc
parent967be53aeec9f02b90f132e0482d27af4c85dd95 (diff)
parent23c35bf0059bd6270218e0b732959e9c754f9812 (diff)
downloadbitcoin-c30f79d418e2e001f1f804a2370db47e5d9ea587.tar.xz
Merge #19940: rpc: Return fee and vsize from testmempoolaccept
23c35bf0059bd6270218e0b732959e9c754f9812 [test] add get_vsize util for more programmatic testing (gzhao408) 2233a93a109b10b6fe0f5f26c2bb529c8de3dde7 [rpc] Return fee and vsize from testmempoolaccept (codeShark149) Pull request description: From #19093 and resolves #19057. Difference from #19093: return `vsize` and `fees` object (similar to `getmempoolentry`) when the test accept is successful. Updates release-notes.md. ACKs for top commit: jnewbery: utACK 23c35bf0059bd6270218e0b732959e9c754f9812 fjahr: utACK 23c35bf instagibbs: reACK https://github.com/bitcoin/bitcoin/pull/19940/commits/23c35bf0059bd6270218e0b732959e9c754f9812 Tree-SHA512: dcb81b7b817a4684e9076bc5d427a6f2d549d2edc66544e718260c4b5f8f1d5ae1d47b754175e9f0c8a3bd8371ce116c2dca0583588d513a7d733d5d614f2b04
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/rawtransaction.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 93e8357e86..1a43ffcc53 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -878,6 +878,11 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
{
{RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
{RPCResult::Type::BOOL, "allowed", "If the mempool allows this tx to be inserted"},
+ {RPCResult::Type::NUM, "vsize", "Virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted (only present when 'allowed' is true)"},
+ {RPCResult::Type::OBJ, "fees", "Transaction fees (only present if 'allowed' is true)",
+ {
+ {RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
+ }},
{RPCResult::Type::STR, "reject-reason", "Rejection string (only present when 'allowed' is false)"},
}},
}
@@ -924,13 +929,22 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
TxValidationState state;
bool test_accept_res;
+ CAmount fee;
{
LOCK(cs_main);
test_accept_res = AcceptToMemoryPool(mempool, state, std::move(tx),
- nullptr /* plTxnReplaced */, false /* bypass_limits */, max_raw_tx_fee, /* test_accept */ true);
+ nullptr /* plTxnReplaced */, false /* bypass_limits */, max_raw_tx_fee, /* test_accept */ true, &fee);
}
result_0.pushKV("allowed", test_accept_res);
- if (!test_accept_res) {
+
+ // Only return the fee and vsize if the transaction would pass ATMP.
+ // These can be used to calculate the feerate.
+ if (test_accept_res) {
+ result_0.pushKV("vsize", virtual_size);
+ UniValue fees(UniValue::VOBJ);
+ fees.pushKV("base", ValueFromAmount(fee));
+ result_0.pushKV("fees", fees);
+ } else {
if (state.IsInvalid()) {
if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS) {
result_0.pushKV("reject-reason", "missing-inputs");