sendtoaddress
don’t have this option at all and sendmany
should by default spend from (lets say) our change.
sendtoaddress
don’t have this option at all and sendmany
should by default spend from (lets say) our change.
minconf
be CoinEligibilityFilter::conf_theirs
?
GetLegacyBalance
is unused and should be removed, no?
.
TBH this kind of stuff should really be identified automatically and fixed before human review takes place – we really need to use better tooling in Travis :-)
-BEGIN VERIFY SCRIPT-
sed -i --regexp-extended -e 's/const CWalletTx ?\* ?pcoin = &/const CWalletTx\& wtx = /g' src/wallet/wallet.cpp
sed -i -e 's/\<pcoin->/wtx./g' src/wallet/wallet.cpp
sed -i -e 's/\<pcoin\>/\&wtx/g' src/wallet/wallet.cpp
-END VERIFY SCRIPT-
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, 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.
925@@ -929,11 +926,6 @@ static UniValue sendmany(const JSONRPCRequest& request)
926
927 EnsureWalletIsUnlocked(pwallet);
928
929- // Check funds
930- if (totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth)) {
In commit “rpc: Document that minconf is an ignored dummy value” (fae5f874d51c770322fb18cc4050b3f14697de66)
Is this commit description actually accurate? Is this just documenting existing behavior or changing the behavior?
If this commit is changing the behavior, I think there should be release notes saying min_depth is now ignored. Also, maybe this should raise an error if min_depth is passed and is set to anything other than 1.
If this commit isn’t changing behavior, and min depth was ignored all along, the commit message should directly say it was already ignored, and maybe explain how setting a value didn’t have any effect. Also, there could still be release notes saying that sendmany will now throw “Insufficient funds” (from CreateTransaction) instead of “Wallet has insufficient funds.”
Strictly speaking it is changing behavior, since it might throw a different rpc error (or none at all and succeed) now. However, the previous behavior was not well specified by the documentation string of minconf
. And my attempt at making sense of it failed:
By not throwing an error the client may think min_depth
is still used and never update his code.
Also, maybe this should raise an error if min_depth is passed and is set to anything other than 1.
I think @ryanofsky suggestion should be considered.
That is just going to open a can of worms. I think, either it should throw for any value (including 1, the default), since that was ignored before as well, or never throw at all.
If it throws for all values, you might as well just remove the parameter and break the interface. Though, then that’d have to go through a -deprecatedrpc
cycle. I don’t think this effort is justified. Please explain why ignoring this parameter could lead to any meaningful issues
I can see both sides. In this case though, I think we should just silently ignore. I don’t see any downside to clients continuing to specify this and having it ignored. The help text has been updated to “ignore dummy value”, so I don’t think there’s any chance of users being confused by this.
Enforcing that this be set to 1 would give the impression that the passed value actually does something.
1
is not going them to read them either, but just modify their code to pass 1
, what is the point then?
The help text is worthless for existing software.
For existing software, the only thing throwing an error would do is make the user change the client so it sets this to 1 or omit it. The end result will be the same as if the RPC doesn’t throw an error, except there would be more disruption for users during transition.
If this PR were actually deprecating useful functionality, then I’d agree with you, but it’s not. This option has never done what the help text implies that it should do.
utACK fabfb79673d6bf9bff5258cd709d8294e77c1764
The fact that this parameter was not covered by any test cases is indication that it was underspecified.
Nice incidental correction of coin -> wtx.
73+Note: some low-level RPC changes mainly useful for testing are described in the
74+Low-level Changes section below.
75+
76+* The `sendmany` RPC had an argument `minconf` that was not well specified and
77+ would lead to RPC errors even when the wallet's coin selection would succeed.
78+ The `sendtoaddress` RPC never had this check, so to normalize the behavior,
sendtoaddress
was kind of soft-deprecated by sendmany
.
Since some people reading the release notes are probably going to end up here confused (I did), I thought it would be useful to write my understanding here.
The min_conf argument to sendmany was functionally part of the now gone “accounts” system. … that’s also why it was only an argument to sendmany and not sendtoaddress, since sendmany had an account parameter (and as luke-noted, sendtoaddress was soft-deprecated).
The accounts system was intended to provide the backing logic for a shared user wallet (in particular, mybitcoin which went away after “losing” half its users funds). Especially after the mental model of UTXO and such started becoming understood by users, accounts functions were commonly misunderstood to be coincontrol features, but they never were: The wallet was written almost entirely with the view that the underlying output model would be hidden from the user. And for a shared-wallet it would be generally undesirable to have multiple users mean separate wallets because of the loss of fee efficiency, in any case.
The purpose of min_conf was accurately documented in the help: Use the balance according to a specified number of confirmations. This did not mean use the coins of a specific depth: remember accounts were not a coin-control feature, and the abstraction of coins was originally intended to be completely hidden from the users.
The reason an accounts-based shared wallet would want to use this is to prevent an attack where a user deposits some coins, waits for 1 conf (so their balance goes up) then withdraw that amount (which they can because their balance is high enough) which then ends up selecting some different >6 conf coins (since that is coinselection’s extremely strong preference) … then reorg the chain 1 block to claw their payment back while leaving the withdraw in place. … leaving the user with a negative balance which they never repay. By setting min_conf to 6, a permitted payment would not result in the user’s balance becoming negative if there was a 6 or fewer block reorg + doublespend.
Though I’m not sure of it, I would be surprised if this option wasn’t added in direct response to actual losses.
Since the accounts system is gone, this setting doesn’t have a real use anymore AFAICT. It probably would have been better if the release notes had said that, rather than suggesting some coin-controlly things which this setting never accomplished, not intended to accomplish, nor was documented to accomplish.
It’s possible someone was using it to make sure they didn’t overspend relative to their well confirmed coins and end up insolvent and owing people for payments in the event of a reorg beyond what they can make good for– but I doubt it. If so, I believe there is currently no alternative functionality available for them (certainly not any of the options mentioned in the release notes).
Nor could the setting really have been re-purposed to some coin control-ish purpose, even though filtering your coins by depth is a pretty reasonable ask– because change and third party payments really need to be treated distinctly if you do that kind of filtering because otherwise any filtering means you can’t use your own change which is extremely disruptive and surprising, particularly since the interface mostly hides the fact that transacting temporarily kicks an essentially random amount of your balance to unconfirmed status. Any kind of min_conf coin control setting would probably need to work like the coin-selection does and have a separate argument for change (which would almost always be kept at the default of 0). … maybe such a feature would even need three categories (immature coinbases) or four (change from segwit-only txn should probably be handled differently!). yuck: coin control is hard.
What does soft-deprecated mean?
I think it means that there is an similar call that should be preferred, but the original one will never be removed.
MarcoFalke
promag
practicalswift
DrahtBot
ryanofsky
jnewbery
luke-jr
gmaxwell
Labels
Wallet
RPC/REST/ZMQ
Milestone
0.19.0