-
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
base: develop
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -522,6 +522,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); | ||
|
|
||
|
|
@@ -572,6 +573,10 @@ 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()); | ||
| } | ||
|
Comment on lines
+576
to
+578
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 { | ||
|
|
@@ -753,6 +758,7 @@ RPCHelpMan fundrawtransaction() | |
| }, | ||
| }, | ||
| }, | ||
| {"use_cj", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use CoinJoin funds only"}, | ||
| }, | ||
| FundTxDoc()), | ||
| "options"}, | ||
|
|
@@ -958,6 +964,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()), | ||
| "options"}, | ||
|
|
@@ -1064,6 +1071,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() | ||
| ), | ||
|
|
@@ -1138,6 +1146,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
+1149
to
+1151
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 👍 / 👎.
Comment on lines
+1149
to
+1151
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.
Proposed fix@@
} else if (options.exists("inputs")) {
for (const CTxIn& input : rawTx.vin) {
+ if (coin_control.IsUsingCoinJoin() && !pwallet->IsFullyMixed(input.prevout)) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER,
+ strprintf("Input not available. UTXO (%s:%d) is not fully mixed while use_cj=true.",
+ input.prevout.hash.ToString(), input.prevout.n));
+ }
if (pwallet->IsSpent(input.prevout)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Input not available. UTXO (%s:%d) was already spent.", input.prevout.hash.ToString(), input.prevout.n));
}🤖 Prompt for AI Agents
Collaborator
Author
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. no, it works as expected: 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.
My original concern was specifically about the narrower case where 🧠 Learnings used |
||
|
|
||
| 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use_cjbecomes accepted inwalletcreatefundedpsbtwithout being documented there.Because
FundTransaction()is shared, adding"use_cj"to this strict options schema also enables it forwalletcreatefundedpsbt(which still doesn’t advertise it in its options docs). Please either document it there too or explicitly gate it per-RPC to avoid undocumented API behavior.🤖 Prompt for AI Agents