Skip to content

Commit 820d31f

Browse files
committed
Add "bip125-replaceable" flag to mempool RPCs
This affects getrawmempool, getmempoolentry, getmempoolancestors and getmempooldescendants.
1 parent a785bc3 commit 820d31f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/rpc/blockchain.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <core_io.h>
1616
#include <policy/feerate.h>
1717
#include <policy/policy.h>
18+
#include <policy/rbf.h>
1819
#include <primitives/transaction.h>
1920
#include <rpc/server.h>
2021
#include <streams.h>
@@ -376,7 +377,8 @@ std::string EntryDescriptionString()
376377
" ... ]\n"
377378
" \"spentby\" : [ (array) unconfirmed transactions spending outputs from this transaction\n"
378379
" \"transactionid\", (string) child transaction id\n"
379-
" ... ]\n";
380+
" ... ]\n"
381+
" \"bip125-replaceable\" : true|false, (boolean) Whether this transaction could be replaced due to BIP125 (replace-by-fee)\n";
380382
}
381383

382384
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
@@ -419,6 +421,17 @@ void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
419421
}
420422

421423
info.pushKV("spentby", spent);
424+
425+
// Add opt-in RBF status
426+
bool rbfStatus = false;
427+
RBFTransactionState rbfState = IsRBFOptIn(tx, mempool);
428+
if (rbfState == RBFTransactionState::UNKNOWN) {
429+
throw JSONRPCError(RPC_MISC_ERROR, "Transaction is not in mempool");
430+
} else if (rbfState == RBFTransactionState::REPLACEABLE_BIP125) {
431+
rbfStatus = true;
432+
}
433+
434+
info.pushKV("bip125-replaceable", rbfStatus);
422435
}
423436

424437
UniValue mempoolToJSON(bool fVerbose)

0 commit comments

Comments
 (0)