API: txprepare for multiple outputs#2964
Conversation
|
|
Thank you, I'll restore |
65974ea to
749cc8f
Compare
withdraw/txprepare for multiple addressestxprepare for multiple outputs
42658a2 to
b349554
Compare
84690ed to
5f56928
Compare
niftynei
left a comment
There was a problem hiding this comment.
This is great! A few nits about naming conventions, otherwise it's a nice improvement.
5205197 to
0cbd560
Compare
60bd664 to
b75daaf
Compare
b75daaf to
962041f
Compare
e3a162d to
316f125
Compare
316f125 to
691012b
Compare
7eb4503 to
77883f2
Compare
| } | ||
|
|
||
| if (i == 0) | ||
| (*utx)->wtx->amount = AMOUNT_SAT(0); |
There was a problem hiding this comment.
we should do this before the loop, right after we initialize all_funds = false
There was a problem hiding this comment.
Yes, thank you. Corrected.
There was a problem hiding this comment.
Here shouldn't be changed:
At the beginning, we initial the (*utx)->wtx->amount as AMOUNT_SAT(-1ULL).
This is the max permissible for wallet_select_all.
if (amount_sat_eq(*amount, AMOUNT_SAT(-1ULL))) {
if (outputstok->size > 1)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"outputs[%zi]: this destination wants"
" all satoshi. The count of outputs"
" can't be more than 1. ", i);
(*utx)->wtx->all_funds = true;
break;
}
if (i == 0)
(*utx)->wtx->amount = AMOUNT_SAT(0);
After handling the all case, we can initial (*utx)->wtx->amount again.
There was a problem hiding this comment.
then we're in a split mode, because you've initialized all_funds to be false, but left the wtx->amount pegged at what basically signifies all_funds. this is not ideal.
the wtx amount should be set to zero at the loop start along with the all_funds flag. in the case that the *amount is the max, then set (utx)->wtx->amount to be *amount before breaking. this keeps the state fields of the wtx in sync.
There was a problem hiding this comment.
Yes, I got your idea. It's better 👍
|
Few minor nits, otherwise lgtm |
77883f2 to
e8f98ed
Compare
|
Travis shows that |
e8f98ed to
26c321c
Compare
|
Rebased and solved the bug.(The reason is here ). |
5a8a507 to
a2b9486
Compare
a2b9486 to
4103785
Compare
|
ACK 08882c7 |
Fix #2679
withdrawandtxprepare:withdraw 'output' ['feerate'] ['minconf']txprepare 'output' ['feerate'] ['minconf']
The 'output' is the array of outputs that must specify 'destination' and 'satoshi'.
Its format is like:
[{'destination': address1, 'satoshi': satoshi1}, {'destination': address2, 'satoshi': satoshi2}, ...]
or
[{'destination': address, 'satoshi': "all"}]).
There's also 2 related questions:1. Do you think thisoutputarray is suitable?2. About the testtest_mutiple_withdraw, it looks a bit duplicative withtest_withdraw. Should I merge these two tests?EDIT: Remove the change of withdraw, only make txprepare support mutiple outputs.