mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
rpc: Default rbf enabled
This commit is contained in:
parent
e3c33637ba
commit
61d9149e78
6 changed files with 14 additions and 11 deletions
|
@ -159,7 +159,7 @@ static std::vector<RPCArg> CreateTxDoc()
|
|||
},
|
||||
},
|
||||
{"locktime", RPCArg::Type::NUM, RPCArg::Default{0}, "Raw locktime. Non-0 value also locktime-activates inputs"},
|
||||
{"replaceable", RPCArg::Type::BOOL, RPCArg::Default{false}, "Marks this transaction as BIP125-replaceable.\n"
|
||||
{"replaceable", RPCArg::Type::BOOL, RPCArg::Default{true}, "Marks this transaction as BIP125-replaceable.\n"
|
||||
"Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
|
||||
};
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ static RPCHelpMan createrawtransaction()
|
|||
}, true
|
||||
);
|
||||
|
||||
bool rbf = false;
|
||||
std::optional<bool> rbf;
|
||||
if (!request.params[3].isNull()) {
|
||||
rbf = request.params[3].isTrue();
|
||||
}
|
||||
|
@ -1453,7 +1453,7 @@ static RPCHelpMan createpsbt()
|
|||
}, true
|
||||
);
|
||||
|
||||
bool rbf = false;
|
||||
std::optional<bool> rbf;
|
||||
if (!request.params[3].isNull()) {
|
||||
rbf = request.params[3].isTrue();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <util/strencodings.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, bool rbf)
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf)
|
||||
{
|
||||
if (outputs_in.isNull()) {
|
||||
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
|
|||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be negative");
|
||||
|
||||
uint32_t nSequence;
|
||||
if (rbf) {
|
||||
|
||||
if (rbf.value_or(true)) {
|
||||
nSequence = MAX_BIP125_RBF_SEQUENCE; /* CTxIn::SEQUENCE_FINAL - 2 */
|
||||
} else if (rawTx.nLockTime) {
|
||||
nSequence = CTxIn::MAX_SEQUENCE_NONFINAL; /* CTxIn::SEQUENCE_FINAL - 1 */
|
||||
|
@ -132,7 +133,7 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
|
|||
}
|
||||
}
|
||||
|
||||
if (rbf && rawTx.vin.size() > 0 && !SignalsOptInRBF(CTransaction(rawTx))) {
|
||||
if (rbf.has_value() && rbf.value() && rawTx.vin.size() > 0 && !SignalsOptInRBF(CTransaction(rawTx))) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter combination: Sequence number(s) contradict replaceable option");
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
struct bilingual_str;
|
||||
class FillableSigningProvider;
|
||||
|
@ -38,6 +39,6 @@ void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const
|
|||
void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keystore, std::map<COutPoint, Coin>& coins);
|
||||
|
||||
/** Create a transaction from univalue parameters */
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, bool rbf);
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf);
|
||||
|
||||
#endif // BITCOIN_RPC_RAWTRANSACTION_UTIL_H
|
||||
|
|
|
@ -111,7 +111,8 @@ class P2PPermissionsTests(BitcoinTestFramework):
|
|||
'vout': 0,
|
||||
}], outputs=[{
|
||||
ADDRESS_BCRT1_P2WSH_OP_TRUE: 5,
|
||||
}]),
|
||||
}],
|
||||
replaceable=False),
|
||||
)
|
||||
tx.wit.vtxinwit = [CTxInWitness()]
|
||||
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE])]
|
||||
|
|
|
@ -452,7 +452,7 @@ class PSBTTest(BitcoinTestFramework):
|
|||
|
||||
# Creator Tests
|
||||
for creator in creators:
|
||||
created_tx = self.nodes[0].createpsbt(creator['inputs'], creator['outputs'])
|
||||
created_tx = self.nodes[0].createpsbt(inputs=creator['inputs'], outputs=creator['outputs'], replaceable=False)
|
||||
assert_equal(created_tx, creator['result'])
|
||||
|
||||
# Signer tests
|
||||
|
|
|
@ -146,7 +146,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
# Create tx2 using createrawtransaction
|
||||
inputs = [{"txid": utxo_to_use["txid"], "vout": utxo_to_use["vout"]}]
|
||||
outputs = {self.nodes[0].getnewaddress(): 0.999}
|
||||
tx2 = self.nodes[1].createrawtransaction(inputs, outputs)
|
||||
tx2 = self.nodes[1].createrawtransaction(inputs=inputs, outputs=outputs, replaceable=False)
|
||||
tx2_signed = self.nodes[1].signrawtransactionwithwallet(tx2)["hex"]
|
||||
txid_2 = self.nodes[1].sendrawtransaction(tx2_signed)
|
||||
|
||||
|
@ -178,7 +178,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||
utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[1], txid_3)
|
||||
inputs = [{"txid": txid_3, "vout": utxo_to_use["vout"]}]
|
||||
outputs = {self.nodes[0].getnewaddress(): 0.997}
|
||||
tx4 = self.nodes[1].createrawtransaction(inputs, outputs)
|
||||
tx4 = self.nodes[1].createrawtransaction(inputs=inputs, outputs=outputs, replaceable=False)
|
||||
tx4_signed = self.nodes[1].signrawtransactionwithwallet(tx4)["hex"]
|
||||
txid_4 = self.nodes[1].sendrawtransaction(tx4_signed)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue