mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
Merge bitcoin/bitcoin#32896: wallet, rpc: add v3 transaction creation and wallet support
5c8bf7b39edoc: add release notes for version 3 transactions (ishaanam)4ef8065a5etest: add truc wallet tests (ishaanam)5d932e14dbtest: extract `bulk_vout` from `bulk_tx` so it can be used by wallet tests (ishaanam)2cb473d9f2rpc: Support version 3 transaction creation (Bue-von-hon)4c20343b4drpc: Add transaction min standard version parameter (Bue-von-hon)c5a2d08011wallet: don't return utxos from multiple truc txs in AvailableCoins (ishaanam)da8748ad62wallet: limit v3 tx weight in coin selection (ishaanam)85c5410615wallet: mark unconfirmed v3 siblings as mempool conflicts (ishaanam)0804fc3cb1wallet: throw error at conflicting tx versions in pre-selected inputs (ishaanam)cc155226fewallet: set m_version in coin control to default value (ishaanam)2e9617664ewallet: don't include unconfirmed v3 txs with children in available coins (ishaanam)ec2676becdwallet: unconfirmed ancestors and descendants are always truc (ishaanam) Pull request description: This PR Implements the following: - If creating a v3 transaction, `AvailableCoins` doesn't return unconfirmed v2 utxos (and vice versa) - `AvailableCoins` doesn't return an unconfirmed v3 utxo if its transaction already has a child - If a v3 transaction is kicked out of the mempool by a sibling, mark the sibling as a mempool conflict - Throw an error if pre-selected inputs are of the wrong transaction version - Allow setting version to 3 manually in `createrawtransaction` (uses commits from #31936) - Limits a v3 transaction weight in coin selection Closes #31348 To-Do: - [x] Test a v3 sibling conflict kicking out one of our transactions from the mempool - [x] Implement separate size limit for TRUC children - [x] Test that we can't fund a v2 transaction when everything is v3 unconfirmed - [x] Test a v3 sibling conflict being removed from the mempool - [x] Test limiting v3 transaction weight in coin selection - [x] Simplify tests - [x] Add documentation - [x] Test that user-input max weight is not overwritten by truc max weight - [x] Test v3 in RPCs other than `createrawtransaction` ACKs for top commit: glozow: reACK5c8bf7b39eachow101: ACK5c8bf7b39erkrux: ACK5c8bf7b39eTree-SHA512: da8aea51c113e193dd0b442eff765bd6b8dc0e5066272d3e52190a223c903f48788795f32c554f268af0d2607b5b8c3985c648879cb176c65540837c05d0abb5
This commit is contained in:
@@ -119,6 +119,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "createrawtransaction", 1, "outputs" },
|
||||
{ "createrawtransaction", 2, "locktime" },
|
||||
{ "createrawtransaction", 3, "replaceable" },
|
||||
{ "createrawtransaction", 4, "version" },
|
||||
{ "decoderawtransaction", 1, "iswitness" },
|
||||
{ "signrawtransactionwithkey", 1, "privkeys" },
|
||||
{ "signrawtransactionwithkey", 2, "prevtxs" },
|
||||
@@ -167,6 +168,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "walletcreatefundedpsbt", 3, "solving_data"},
|
||||
{ "walletcreatefundedpsbt", 3, "max_tx_weight"},
|
||||
{ "walletcreatefundedpsbt", 4, "bip32derivs" },
|
||||
{ "walletcreatefundedpsbt", 5, "version" },
|
||||
{ "walletprocesspsbt", 1, "sign" },
|
||||
{ "walletprocesspsbt", 3, "bip32derivs" },
|
||||
{ "walletprocesspsbt", 4, "finalize" },
|
||||
@@ -177,6 +179,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "createpsbt", 1, "outputs" },
|
||||
{ "createpsbt", 2, "locktime" },
|
||||
{ "createpsbt", 3, "replaceable" },
|
||||
{ "createpsbt", 4, "version" },
|
||||
{ "combinepsbt", 0, "txs"},
|
||||
{ "joinpsbts", 0, "txs"},
|
||||
{ "finalizepsbt", 1, "extract"},
|
||||
@@ -213,6 +216,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "send", 4, "replaceable"},
|
||||
{ "send", 4, "solving_data"},
|
||||
{ "send", 4, "max_tx_weight"},
|
||||
{ "send", 5, "version"},
|
||||
{ "sendall", 0, "recipients" },
|
||||
{ "sendall", 1, "conf_target" },
|
||||
{ "sendall", 3, "fee_rate"},
|
||||
@@ -230,6 +234,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "sendall", 4, "conf_target"},
|
||||
{ "sendall", 4, "replaceable"},
|
||||
{ "sendall", 4, "solving_data"},
|
||||
{ "sendall", 4, "version"},
|
||||
{ "simulaterawtransaction", 0, "rawtxs" },
|
||||
{ "simulaterawtransaction", 1, "options" },
|
||||
{ "simulaterawtransaction", 1, "include_watchonly"},
|
||||
|
||||
@@ -53,6 +53,8 @@ using node::GetTransaction;
|
||||
using node::NodeContext;
|
||||
using node::PSBTAnalysis;
|
||||
|
||||
static constexpr decltype(CTransaction::version) DEFAULT_RAWTX_VERSION{CTransaction::CURRENT_VERSION};
|
||||
|
||||
static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry,
|
||||
Chainstate& active_chainstate, const CTxUndo* txundo = nullptr,
|
||||
TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS)
|
||||
@@ -158,6 +160,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{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."},
|
||||
{"version", RPCArg::Type::NUM, RPCArg::Default{DEFAULT_RAWTX_VERSION}, "Transaction version"},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -437,7 +440,7 @@ static RPCHelpMan createrawtransaction()
|
||||
if (!request.params[3].isNull()) {
|
||||
rbf = request.params[3].get_bool();
|
||||
}
|
||||
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf);
|
||||
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf, self.Arg<uint32_t>("version"));
|
||||
|
||||
return EncodeHexTx(CTransaction(rawTx));
|
||||
},
|
||||
@@ -1679,7 +1682,7 @@ static RPCHelpMan createpsbt()
|
||||
if (!request.params[3].isNull()) {
|
||||
rbf = request.params[3].get_bool();
|
||||
}
|
||||
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf);
|
||||
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], rbf, self.Arg<uint32_t>("version"));
|
||||
|
||||
// Make a blank psbt
|
||||
PartiallySignedTransaction psbtx;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <tinyformat.h>
|
||||
#include <univalue.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/string.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/translation.h>
|
||||
|
||||
@@ -143,7 +144,7 @@ void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
|
||||
}
|
||||
}
|
||||
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf)
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf, const uint32_t version)
|
||||
{
|
||||
CMutableTransaction rawTx;
|
||||
|
||||
@@ -154,6 +155,11 @@ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniVal
|
||||
rawTx.nLockTime = nLockTime;
|
||||
}
|
||||
|
||||
if (version < TX_MIN_STANDARD_VERSION || version > TX_MAX_STANDARD_VERSION) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, version out of range(%d~%d)", TX_MIN_STANDARD_VERSION, TX_MAX_STANDARD_VERSION));
|
||||
}
|
||||
rawTx.version = version;
|
||||
|
||||
AddInputs(rawTx, inputs_in, rbf);
|
||||
AddOutputs(rawTx, outputs_in);
|
||||
|
||||
|
||||
@@ -53,6 +53,6 @@ std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& out
|
||||
void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in);
|
||||
|
||||
/** Create a transaction from univalue parameters */
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf);
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf, const uint32_t version);
|
||||
|
||||
#endif // BITCOIN_RPC_RAWTRANSACTION_UTIL_H
|
||||
|
||||
@@ -731,6 +731,7 @@ TMPL_INST(CheckRequiredOrDefault, const UniValue&, *CHECK_NONFATAL(maybe_arg););
|
||||
TMPL_INST(CheckRequiredOrDefault, bool, CHECK_NONFATAL(maybe_arg)->get_bool(););
|
||||
TMPL_INST(CheckRequiredOrDefault, int, CHECK_NONFATAL(maybe_arg)->getInt<int>(););
|
||||
TMPL_INST(CheckRequiredOrDefault, uint64_t, CHECK_NONFATAL(maybe_arg)->getInt<uint64_t>(););
|
||||
TMPL_INST(CheckRequiredOrDefault, uint32_t, CHECK_NONFATAL(maybe_arg)->getInt<uint32_t>(););
|
||||
TMPL_INST(CheckRequiredOrDefault, const std::string&, CHECK_NONFATAL(maybe_arg)->get_str(););
|
||||
|
||||
bool RPCHelpMan::IsValidNumArgs(size_t num_args) const
|
||||
|
||||
Reference in New Issue
Block a user