-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add use_cj feature to RPCs send, sendall and fundrawtransaction #7261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,7 @@ static UniValue FinishTransaction(const std::shared_ptr<CWallet> pwallet, const | |
| CTransactionRef tx(MakeTransactionRef(std::move(mtx))); | ||
| result.pushKV("txid", tx->GetHash().GetHex()); | ||
| if (add_to_wallet && !psbt_opt_in) { | ||
| pwallet->CommitTransaction(tx, {}, /*orderForm*/ {}); | ||
| pwallet->CommitTransaction(tx, options["use_cj"].isTrue() ? mapValue_t{{"DS", "1"}} : mapValue_t{}, /*orderForm*/ {}); | ||
| } else { | ||
| result.pushKV("hex", hex); | ||
| } | ||
|
|
@@ -545,6 +545,7 @@ void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out, | |
| {"conf_target", UniValueType(UniValue::VNUM)}, | ||
| {"estimate_mode", UniValueType(UniValue::VSTR)}, | ||
| {"input_sizes", UniValueType(UniValue::VARR)}, | ||
| {"use_cj", UniValueType(UniValue::VBOOL)}, | ||
| }, | ||
| true, true); | ||
|
|
||
|
|
@@ -595,6 +596,19 @@ void FundTransaction(CWallet& wallet, CMutableTransaction& tx, CAmount& fee_out, | |
| if (options.exists("subtractFeeFromOutputs") || options.exists("subtract_fee_from_outputs") ) | ||
| subtractFeeFromOutputs = (options.exists("subtract_fee_from_outputs") ? options["subtract_fee_from_outputs"] : options["subtractFeeFromOutputs"]).get_array(); | ||
|
|
||
| if (options.exists("use_cj")) { | ||
| coinControl.UseCoinJoin(options["use_cj"].get_bool()); | ||
| if (coinControl.IsUsingCoinJoin()) { | ||
| // Preset inputs stay in the transaction even though coin selection | ||
| // ignores non-mixed ones, so reject them here instead | ||
| for (const CTxIn& txin : tx.vin) { | ||
| if (!wallet.IsFullyMixed(txin.prevout)) { | ||
| throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Input not available. UTXO (%s:%d) is not fully mixed.", txin.prevout.hash.ToString(), txin.prevout.n)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+599
to
+610
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Setting Useful? React with 👍 / 👎. |
||
|
|
||
| SetFeeEstimateMode(wallet, coinControl, options["conf_target"], options["estimate_mode"], options["fee_rate"], override_min_fee); | ||
| } | ||
| } else { | ||
|
|
@@ -776,6 +790,7 @@ RPCHelpMan fundrawtransaction() | |
| }, | ||
| }, | ||
| }, | ||
| {"use_cj", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use CoinJoin funds only"}, | ||
| }, | ||
| FundTxDoc()), | ||
| RPCArgOptions{.oneline_description="options"}}, | ||
|
|
@@ -982,6 +997,7 @@ RPCHelpMan send() | |
| {"vout_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The zero-based output index, before a change output is added."}, | ||
| }, | ||
| }, | ||
| {"use_cj", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use CoinJoin funds only"}, | ||
| }, | ||
| FundTxDoc()), | ||
| RPCArgOptions{.oneline_description="options"}}, | ||
|
|
@@ -1088,6 +1104,7 @@ RPCHelpMan sendall() | |
| {"lock_unspents", RPCArg::Type::BOOL, RPCArg::Default{false}, "Lock selected unspent outputs"}, | ||
| {"psbt", RPCArg::Type::BOOL, RPCArg::DefaultHint{"automatic"}, "Always return a PSBT, implies add_to_wallet=false."}, | ||
| {"send_max", RPCArg::Type::BOOL, RPCArg::Default{false}, "When true, only use UTXOs that can pay for their own fees to maximize the output amount. When 'false' (default), no UTXO is left behind. send_max is incompatible with providing specific inputs."}, | ||
| {"use_cj", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use CoinJoin funds only"}, | ||
| }, | ||
| FundTxDoc() | ||
| ), | ||
|
|
@@ -1162,6 +1179,10 @@ RPCHelpMan sendall() | |
|
|
||
| coin_control.fAllowWatchOnly = ParseIncludeWatchonly(options["include_watching"], *pwallet); | ||
|
|
||
| if (options.exists("use_cj")) { | ||
| coin_control.UseCoinJoin(options["use_cj"].get_bool()); | ||
| } | ||
|
Comment on lines
+1182
to
+1184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| FeeCalculation fee_calc_out; | ||
| CFeeRate fee_rate{GetMinimumFeeRate(*pwallet, coin_control, &fee_calc_out)}; | ||
| // Do not, ever, assume that it's fine to change the fee rate if the user has explicitly | ||
|
|
@@ -1190,6 +1211,9 @@ RPCHelpMan sendall() | |
| if (!tx || input.prevout.n >= tx->tx->vout.size() || !(pwallet->IsMine(tx->tx->vout[input.prevout.n]) & (coin_control.fAllowWatchOnly ? ISMINE_ALL : ISMINE_SPENDABLE))) { | ||
| throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Input not found. UTXO (%s:%d) is not part of wallet.", input.prevout.hash.ToString(), input.prevout.n)); | ||
| } | ||
| if (coin_control.IsUsingCoinJoin() && !pwallet->IsFullyMixed(input.prevout)) { | ||
| throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Input not available. UTXO (%s:%d) is not fully mixed.", input.prevout.hash.ToString(), input.prevout.n)); | ||
| } | ||
| total_input_value += tx->tx->vout[input.prevout.n].nValue; | ||
| } | ||
| } else { | ||
|
|
@@ -1418,6 +1442,7 @@ RPCHelpMan walletcreatefundedpsbt() | |
| {"vout_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The zero-based output index, before a change output is added."}, | ||
| }, | ||
| }, | ||
| {"use_cj", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use CoinJoin funds only"}, | ||
| }, | ||
| FundTxDoc()), | ||
| RPCArgOptions{.oneline_description="options"}}, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.