mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-01 16:31:33 +01:00
Add "bip125-replaceable" flag to mempool RPCs
This affects getrawmempool, getmempoolentry, getmempoolancestors and getmempooldescendants.
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include <core_io.h>
|
#include <core_io.h>
|
||||||
#include <policy/feerate.h>
|
#include <policy/feerate.h>
|
||||||
#include <policy/policy.h>
|
#include <policy/policy.h>
|
||||||
|
#include <policy/rbf.h>
|
||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <rpc/server.h>
|
#include <rpc/server.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
@@ -376,7 +377,8 @@ std::string EntryDescriptionString()
|
|||||||
" ... ]\n"
|
" ... ]\n"
|
||||||
" \"spentby\" : [ (array) unconfirmed transactions spending outputs from this transaction\n"
|
" \"spentby\" : [ (array) unconfirmed transactions spending outputs from this transaction\n"
|
||||||
" \"transactionid\", (string) child transaction id\n"
|
" \"transactionid\", (string) child transaction id\n"
|
||||||
" ... ]\n";
|
" ... ]\n"
|
||||||
|
" \"bip125-replaceable\" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
||||||
@@ -419,6 +421,17 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
info.pushKV("spentby", spent);
|
info.pushKV("spentby", spent);
|
||||||
|
|
||||||
|
// Add opt-in RBF status
|
||||||
|
bool rbfStatus = false;
|
||||||
|
RBFTransactionState rbfState = IsRBFOptIn(tx, mempool);
|
||||||
|
if (rbfState == RBFTransactionState::UNKNOWN) {
|
||||||
|
throw JSONRPCError(RPC_MISC_ERROR, "Transaction is not in mempool");
|
||||||
|
} else if (rbfState == RBFTransactionState::REPLACEABLE_BIP125) {
|
||||||
|
rbfStatus = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.pushKV("bip125-replaceable", rbfStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue mempoolToJSON(bool fVerbose)
|
UniValue mempoolToJSON(bool fVerbose)
|
||||||
|
|||||||
Reference in New Issue
Block a user