Skip to content

Commit c781a04

Browse files
committed
RPC/rawtransaction: createrawtransaction: Check opt_into_rbf when provided with either value
1 parent bc2e702 commit c781a04

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
@@ -192,6 +192,7 @@ libbitcoin_server_a_SOURCES = \
192192
noui.cpp \
193193
policy/fees.cpp \
194194
policy/policy.cpp \
195+
policy/rbf.cpp \
195196
pow.cpp \
196197
rest.cpp \
197198
rpc/blockchain.cpp \
@@ -233,7 +234,6 @@ libbitcoin_wallet_a_SOURCES = \
233234
wallet/rpcwallet.cpp \
234235
wallet/wallet.cpp \
235236
wallet/walletdb.cpp \
236-
policy/rbf.cpp \
237237
$(BITCOIN_CORE_H)
238238

239239
# crypto primitives library

src/rpc/rawtransaction.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
379379
" ,...\n"
380380
" }\n"
381381
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n"
382-
"4. optintorbf (boolean, optional, default=false) Allow this transaction to be replaced by a transaction with higher fees\n"
382+
"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"
383383
"\nResult:\n"
384384
"\"transaction\" (string) hex string of the transaction\n"
385385

@@ -436,8 +436,6 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
436436
int64_t seqNr64 = sequenceObj.get_int64();
437437
if (seqNr64 < 0 || seqNr64 > std::numeric_limits<uint32_t>::max()) {
438438
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sequence number is out of range");
439-
} else if (seqNr64 <= MAX_BIP125_RBF_SEQUENCE && request.params.size() > 3 && request.params[3].isFalse()) {
440-
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number contradicts optintorbf option");
441439
} else {
442440
nSequence = (uint32_t)seqNr64;
443441
}
@@ -474,6 +472,10 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
474472
}
475473
}
476474

475+
if (request.params.size() > 3 && rbfOptIn != SignalsOptInRBF(rawTx)) {
476+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number(s) contradict optintorbf option");
477+
}
478+
477479
return EncodeHexTx(rawTx);
478480
}
479481

0 commit comments

Comments
 (0)