Skip to content

Commit 9a5a1d7

Browse files
committed
RPC/rawtransaction: createrawtransaction: Check opt_into_rbf when provided with either value
1 parent 23b0fe3 commit 9a5a1d7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ libbitcoin_server_a_SOURCES = \
198198
noui.cpp \
199199
policy/fees.cpp \
200200
policy/policy.cpp \
201+
policy/rbf.cpp \
201202
pow.cpp \
202203
rest.cpp \
203204
rpc/blockchain.cpp \
@@ -240,7 +241,6 @@ libbitcoin_wallet_a_SOURCES = \
240241
wallet/rpcwallet.cpp \
241242
wallet/wallet.cpp \
242243
wallet/walletdb.cpp \
243-
policy/rbf.cpp \
244244
$(BITCOIN_CORE_H)
245245

246246
# crypto primitives library

src/rpc/rawtransaction.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
316316
" ,...\n"
317317
" }\n"
318318
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n"
319-
"4. optintorbf (boolean, optional, default=false) Allow this transaction to be replaced by a transaction with higher fees\n"
319+
"4. optintorbf (boolean, optional, default=false) Allow this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.\n"
320320
"\nResult:\n"
321321
"\"transaction\" (string) hex string of the transaction\n"
322322

@@ -373,8 +373,6 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
373373
int64_t seqNr64 = sequenceObj.get_int64();
374374
if (seqNr64 < 0 || seqNr64 > std::numeric_limits<uint32_t>::max()) {
375375
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sequence number is out of range");
376-
} else if (seqNr64 <= MAX_BIP125_RBF_SEQUENCE && request.params.size() > 3 && request.params[3].isFalse()) {
377-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number contradicts optintorbf option");
378376
} else {
379377
nSequence = (uint32_t)seqNr64;
380378
}
@@ -411,6 +409,10 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
411409
}
412410
}
413411

412+
if (request.params.size() > 3 && rbfOptIn != SignalsOptInRBF(rawTx)) {
413+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number(s) contradict optintorbf option");
414+
}
415+
414416
return EncodeHexTx(rawTx);
415417
}
416418

0 commit comments

Comments
 (0)