Skip to content

Commit 61d9149

Browse files
committed
rpc: Default rbf enabled
1 parent e3c3363 commit 61d9149

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static std::vector<RPCArg> CreateTxDoc()
159159
},
160160
},
161161
{"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"},
162-
{"replaceable", RPCArg::Type::BOOL, RPCArg::Default{false}, "Marks this transaction as BIP125-replaceable.\n"
162+
{"replaceable", RPCArg::Type::BOOL, RPCArg::Default{true}, "Marks this transaction as BIP125-replaceable.\n"
163163
"Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
164164
};
165165
}
@@ -304,7 +304,7 @@ static RPCHelpMan createrawtransaction()
304304
}, true
305305
);
306306

307-
bool rbf = false;
307+
std::optional<bool> rbf;
308308
if (!request.params[3].isNull()) {
309309
rbf = request.params[3].isTrue();
310310
}
@@ -1453,7 +1453,7 @@ static RPCHelpMan createpsbt()
14531453
}, true
14541454
);
14551455

1456-
bool rbf = false;
1456+
std::optional<bool> rbf;
14571457
if (!request.params[3].isNull()) {
14581458
rbf = request.params[3].isTrue();
14591459
}

src/rpc/rawtransaction_util.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <util/strencodings.h>
2222
#include <util/translation.h>
2323

24-
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, bool rbf)
24+
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf)
2525
{
2626
if (outputs_in.isNull()) {
2727
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, output argument must be non-null");
@@ -60,7 +60,8 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
6060
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
6161

6262
uint32_t nSequence;
63-
if (rbf) {
63+
64+
if (rbf.value_or(true)) {
6465
nSequence = MAX_BIP125_RBF_SEQUENCE; /* CTxIn::SEQUENCE_FINAL - 2 */
6566
} else if (rawTx.nLockTime) {
6667
nSequence = CTxIn::MAX_SEQUENCE_NONFINAL; /* CTxIn::SEQUENCE_FINAL - 1 */
@@ -132,7 +133,7 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
132133
}
133134
}
134135

135-
if (rbf && rawTx.vin.size() > 0 && !SignalsOptInRBF(CTransaction(rawTx))) {
136+
if (rbf.has_value() && rbf.value() && rawTx.vin.size() > 0 && !SignalsOptInRBF(CTransaction(rawTx))) {
136137
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number(s) contradict replaceable option");
137138
}
138139

src/rpc/rawtransaction_util.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <map>
99
#include <string>
10+
#include <optional>
1011

1112
struct bilingual_str;
1213
class FillableSigningProvider;
@@ -38,6 +39,6 @@ void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const
3839
void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keystore, std::map<COutPoint, Coin>& coins);
3940

4041
/** Create a transaction from univalue parameters */
41-
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, bool rbf);
42+
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf);
4243

4344
#endif // BITCOIN_RPC_RAWTRANSACTION_UTIL_H

test/functional/p2p_permissions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def check_tx_relay(self):
111111
'vout': 0,
112112
}], outputs=[{
113113
ADDRESS_BCRT1_P2WSH_OP_TRUE: 5,
114-
}]),
114+
}],
115+
replaceable=False),
115116
)
116117
tx.wit.vtxinwit = [CTxInWitness()]
117118
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]

test/functional/rpc_psbt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def run_test(self):
452452

453453
# Creator Tests
454454
for creator in creators:
455-
created_tx = self.nodes[0].createpsbt(creator['inputs'], creator['outputs'])
455+
created_tx = self.nodes[0].createpsbt(inputs=creator['inputs'], outputs=creator['outputs'], replaceable=False)
456456
assert_equal(created_tx, creator['result'])
457457

458458
# Signer tests

test/functional/wallet_listtransactions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def get_unconfirmed_utxo_entry(node, txid_to_match):
146146
# Create tx2 using createrawtransaction
147147
inputs = [{"txid": utxo_to_use["txid"], "vout": utxo_to_use["vout"]}]
148148
outputs = {self.nodes[0].getnewaddress(): 0.999}
149-
tx2 = self.nodes[1].createrawtransaction(inputs, outputs)
149+
tx2 = self.nodes[1].createrawtransaction(inputs=inputs, outputs=outputs, replaceable=False)
150150
tx2_signed = self.nodes[1].signrawtransactionwithwallet(tx2)["hex"]
151151
txid_2 = self.nodes[1].sendrawtransaction(tx2_signed)
152152

@@ -178,7 +178,7 @@ def get_unconfirmed_utxo_entry(node, txid_to_match):
178178
utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[1], txid_3)
179179
inputs = [{"txid": txid_3, "vout": utxo_to_use["vout"]}]
180180
outputs = {self.nodes[0].getnewaddress(): 0.997}
181-
tx4 = self.nodes[1].createrawtransaction(inputs, outputs)
181+
tx4 = self.nodes[1].createrawtransaction(inputs=inputs, outputs=outputs, replaceable=False)
182182
tx4_signed = self.nodes[1].signrawtransactionwithwallet(tx4)["hex"]
183183
txid_4 = self.nodes[1].sendrawtransaction(tx4_signed)
184184

0 commit comments

Comments
 (0)