-
Notifications
You must be signed in to change notification settings - Fork 118
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
StaticAddr: Withdraw arbitrary amounts #860
base: master
Are you sure you want to change the base?
Conversation
We remove the static address client and add its rpcs into the SwapClient
Deposit schema extension with a withdrawal sweep address. If the user selects a deposit for withdrawal the destination address of the sweep is stored here.
A new rpc for deposit withdrawals is added. A withdrawal cooperatively spends the 2/2 musig deposit outpoint to a client-specified address.
A server endpoint to obtain a partial sig to cooperatively spend a 2/2 musig deposit outpoint.
4f2ff5d
to
f7af7b4
Compare
5b68e42
to
fb9562b
Compare
f7af7b4
to
827a65b
Compare
818562f
to
9342b0f
Compare
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.
LGTM 🎉
I left few comments.
Also I notices that there are no tests in staticaddr/withdraw
package. Does it make sense to add some to cover all withdrawing cases (full amount, with change, gifting dust change to miners)?
outpoints []wire.OutPoint, destAddr string, satPerVbyte int64) (string, | ||
string, error) { | ||
outpoints []wire.OutPoint, destAddr string, satPerVbyte int64, | ||
amount int64) (string, string, error) { |
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 propose to add to godoc, that amount=0 means "withdraw everything".
} | ||
|
||
addressParams, err := m.cfg.AddressManager.GetStaticAddressParameters( | ||
ctx, | ||
// Send change back to the static address. |
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 propose this change to make it more clear that address is the same.
s/to the static address/to the same static address/
// the withdrawal. | ||
return nil, 0, 0, fmt.Errorf("the change doesn't " + | ||
"cover for fees. Consider lowering the fee " + | ||
"rate or increase the withdrawal amount") |
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.
s/increase/decrease/ IIUC
withdrawalAmount = selectedWithdrawalAmount | ||
|
||
default: | ||
// If the fees eat into our withdrawal amount, we fail |
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.
Actually, the feeWithChange fees eat into our withdrawal amount, but this doesn't mean that feeWithoutChange do, since it is lower than feeWithChange. This means, that some amounts fail, even though it is possible to withdraw without change. And we fallback to withdrawing without change in general case when it is not enough funds for the change. So I think for consistency we should do the same here. Can we replace case change-feeWithChange >= 0:
with case change-feeWithoutChange >= 0:
above?
This PR adds an amount field to the withdrawal rpc.
It allows to withdraw a fraction of the sum of selected deposits to withdraw. The change is sent back to the static address.
If the change is below the dust limit it goes towards miner fees, but warns the user beforehand.