-
Notifications
You must be signed in to change notification settings - Fork 38.7k
rpc: add minconf/maxconf options to sendall and fund transaction calls #25375
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
ACK 0f023da
Tested minconf argument on regtest with:
$ bitcoin-cli generatetoaddress 102 bcrt1qjjdvpcz3l2p4q2y7zc6ztkk3rvagke248y6ckm
$ bitcoin-cli listunspent
[
{
"txid": "56a91239cfcff53da811ae1969bb6e8e288f15ab58cac8fe455ea906a3b51ecb",
"vout": 0,
"address": "bcrt1qjjdvpcz3l2p4q2y7zc6ztkk3rvagke248y6ckm",
"label": "",
"scriptPubKey": "0014949ac0e051fa8350289e163425dad11b3a8b6555",
"amount": 50.00000000,
"confirmations": 101,
"spendable": true,
"solvable": true,
"desc": "wpkh([ae30e814/84'/1'/0'/0/0]020a3db12de02b1f4bbb5e5016f7cebaa427e0c60d20b95ebc552ceb97c86f3722)#n2vukszk",
"safe": true
},
{
"txid": "f1257f379856d91401d27229dbdf797802a521edb6f958bc884e316265a48cfc",
"vout": 0,
"address": "bcrt1qjjdvpcz3l2p4q2y7zc6ztkk3rvagke248y6ckm",
"label": "",
"scriptPubKey": "0014949ac0e051fa8350289e163425dad11b3a8b6555",
"amount": 50.00000000,
"confirmations": 102,
"spendable": true,
"solvable": true,
"desc": "wpkh([ae30e814/84'/1'/0'/0/0]020a3db12de02b1f4bbb5e5016f7cebaa427e0c60d20b95ebc552ceb97c86f3722)#n2vukszk",
"safe": true
}
]
$ bitcoin-cli createrawtransaction '[]' '{"data":"505220233235333735"}'
02000000000100000000000000000b6a0950522023323533373500000000
$ bitcoin-cli fundrawtransaction "02000000000100000000000000000b6a0950522023323533373500000000" "{\"minconf\": 102}"
{
"hex": "0200000001fc8ca46562314e88bc58f9b6ed21a5027879dfdb2972d20114d95698377f25f10000000000feffffff0272f1052a010000002251209b08765d5b558137195f9b3b5b4f5ceaffddcac91590e76f904fdde08cc033bb00000000000000000b6a0950522023323533373500000000",
"fee": 0.00000142,
"changepos": 0
}
$ bitcoin-cli decoderawtransaction 0200000001fc8ca46562314e88bc58f9b6ed21a5027879dfdb2972d20114d95698377f25f10000000000feffffff0272f1052a010000002251209b08765d5b558137195f9b3b5b4f5ceaffddcac91590e76f904fdde08cc033bb00000000000000000b6a0950522023323533373500000000
{
"txid": "4974082891c14f96170f2af7f381e3a6f9510cb9e42841b1e12463f09b164ad5",
"hash": "4974082891c14f96170f2af7f381e3a6f9510cb9e42841b1e12463f09b164ad5",
"version": 2,
"size": 114,
"vsize": 114,
"weight": 456,
"locktime": 0,
"vin": [
{
"txid": "f1257f379856d91401d27229dbdf797802a521edb6f958bc884e316265a48cfc",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"sequence": 4294967294
}
],
"vout": [
{
"value": 49.99999858,
"n": 0,
"scriptPubKey": {
"asm": "1 9b08765d5b558137195f9b3b5b4f5ceaffddcac91590e76f904fdde08cc033bb",
"desc": "addr(bcrt1pnvy8vh2m2kqnwx2lnva4kn6uatlamjkfzkgwwmusflw7prxqxwas8y08ed)#4mpq27kr",
"hex": "51209b08765d5b558137195f9b3b5b4f5ceaffddcac91590e76f904fdde08cc033bb",
"address": "bcrt1pnvy8vh2m2kqnwx2lnva4kn6uatlamjkfzkgwwmusflw7prxqxwas8y08ed",
"type": "witness_v1_taproot"
}
},
{
"value": 0.00000000,
"n": 1,
"scriptPubKey": {
"asm": "OP_RETURN 505220233235333735",
"desc": "raw(6a09505220233235333735)#wxsnvgu2",
"hex": "6a09505220233235333735",
"type": "nulldata"
}
}
]
}
$ bitcoin-cli fundrawtransaction "02000000000100000000000000000b6a0950522023323533373500000000" "{\"minconf\": 103}"
error code: -4
error message:
Insufficient funds
nit: If no UTXO available in wallet with minconf confirmations, the error could be specific to help the user. Example: Insufficient funds with required confirmations
It's actually quite difficult currently to get more specific errors out of coin selection. There's quite a bit of plumbing needed that does not currently exist. #25218 and #24845 add a lot of what is needed to get such errors, but there's still an additional issue where it is hard to tell whether the insufficient funds is due to this particular filter or something else in coin selection. |
w0xlt
left a comment
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.
Code Review ACK 0f023da
|
Perhaps this same option could be included in |
|
This seems like a subset of #22049 |
0f023da to
1e14aea
Compare
|
Changes made since last push: |
Yes, I didn't see that one since it didn't mention the issue I was looking at. I took a look at the other PR and it looks like the main differences, disregarding the tests, are that this one doesn't implement |
|
I'm closing this PR as it is quite similar to #22049 |
|
@ishaanam As #22049 has been abandoned, perhaps copy and rebase it here? P.S. I still have a rebased version at master...luke-jr:rpc_fundtx_minmaxconf |
I agree with @luke-jr , its important to fix the issue not the author or pr and #22049 is abandoned |
7e24831 to
3f0f67c
Compare
I have reopened this PR, thanks for rebasing #22049! |
ghost
left a comment
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.
reACK 3f0f67c
3f0f67c to
a7ab096
Compare
|
Rebased |
f38eb81 to
18e277f
Compare
18e277f to
b3a3cb1
Compare
furszy
left a comment
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.
Almost there, code reviewed b3a3cb14.
Left a last finding and it's ready to go.
b3a3cb1 to
24c906b
Compare
furszy
left a comment
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.
ACK 24c906b
|
ACK 24c906b3311336ccaf5ea9c70da5ebde6f1cd041 |
murchandamus
left a comment
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.
I noticed that 1e14aea added a test for send in test/functional/wallet_send.py, but that test does not seem to be part of the latest change set. Is it possible that the send test got lost accidentally or did I miss the reasoning why it got removed?
24c906b to
41ebc2b
Compare
murchandamus
left a comment
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.
ACK 41ebc2b0294941d12980e19307bd991f9ff85301
… fund calls Enables users to craft BIP-125 replacements with changes to the output list, ensuring that if additional funds are needed they will be added.
41ebc2b to
cfe5aeb
Compare
|
Rebased for silent merge conflict. |
murchandamus
left a comment
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.
ACK cfe5aeb
| if (coin_control.m_max_depth < coin_control.m_min_depth) { | ||
| throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("maxconf can't be lower than minconf: %d < %d", coin_control.m_max_depth, coin_control.m_min_depth)); |
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.
Note to myself/other reviewers . m_min_depth is initialized to DEFAULT_MIN_DEPTH = 0 in coincontrol.h, which is why this check of m_max_depth will always be defined and weed out negative numbers.
|
ACK cfe5aeb |
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.
diff ACK cfe5aeb, only a non-blocking nit.
|
|
||
| self.log.info("Minconf") | ||
| self.nodes[1].createwallet(wallet_name="minconfw") | ||
| minconfw= self.nodes[1].get_wallet_rpc("minconfw") |
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.
nit:
missing space
| minconfw= self.nodes[1].get_wallet_rpc("minconfw") | |
| minconfw = self.nodes[1].get_wallet_rpc("minconfw") |
| "Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.\n" | ||
| "If that happens, you will need to fund the transaction with different inputs and republish it."}, | ||
| {"minconf", RPCArg::Type::NUM, RPCArg::Default{0}, "If add_inputs is specified, require inputs with at least this many confirmations."}, | ||
| {"maxconf", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "If add_inputs is specified, require inputs with at most this many confirmations."}, |
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.
nit: Looks like this should be documented as (optional) in the RPC doc output. In theory this instance can be fixed by replacing OMITTED with OMITTED_NAMED_ARG, however a more complete fix is in #26706
(Same for other "maxconf" in this pull)
|
@harding |
… fund calls Enables users to craft BIP-125 replacements with changes to the output list, ensuring that if additional funds are needed they will be added. Github-Pull: bitcoin#25375 Rebased-From: 3e14de57e0c1bd7692deadfde9f99b1683e5becd
Github-Pull: bitcoin#25375 Rebased-From: 18e277fcf261ebb66cf7e8a25b380e4d6da9111f
This PR adds a "minconf" option to
fundrawtransaction,walletcreatefundedpsbt, andsendall.Alternative implementation of #14641
Fixes #14542
Edit: This PR now also adds this option to
send