-
Notifications
You must be signed in to change notification settings - Fork 121
sweepbatcher: fixes for presigned mode #952
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: master
Are you sure you want to change the base?
Conversation
This is needed to have multiple spending registrations running and to send a notification to a specific spending registration.
In case of a reorg sweeps should not go to another batch but stay in the current batch until it is fully confirmed. Only after that the remaining sweeps are re-added to another batch. Field sweep.completed is now set to true only for fully-confirmed sweeps. In handleConf we now use batch.persist() (i.e. store.UpdateSweepBatch) instead of ConfirmBatch, because we set not only Confirmed flag, but also batchTxid.
There were two mistakes. In case of a swap with multiple sweeps only the fee of the first sweep of a swap was accounted. Rounding diff (the remainder) was attributed to all the sweeps rather than to the first (primary) sweep of the batch. The sweep to attribute the remainder was chosen by comparing SignatureScript which is always empty. New approach is to find the primary sweep and to compare its outpoint directly.
This is needed because sweepbatcher can use this channel in multiple select statements to unblock itself if the caller cancels.
It doesn't need loopdb, so remove that code.
Make sure that broadcasted tx has feeRate >= minRelayFee. Make sure that feeRate of broadcasted tx doesn't decrease.
Method Presign is not as reliable as SignTx, because it checks transaction by txid and can miss for example if LockTime is different. SignTx can do everything Presign was used for.
For presigned possible remaining groups, the destination address of the current batch was used instead of the destination address of an expected future batch. TODO: reproduce in unit test "purged". For this, each swap should have a separate destination 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.
Very nice work @starius, I did a first pass of the PR.
|
||
// Dispatch the sweep notifier, we don't care about the outcome | ||
// of this action so we don't wait for it. | ||
go func() { |
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.
we have to pass in the sweep
and spendDetail
, otherwise we might launch the goroutine for the same sweep.
func (b *batch) handleConf(ctx context.Context, | ||
conf *chainntnfs.TxConfirmation) error { | ||
|
||
spendTx := conf.Tx |
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: not likely, but conf.Tx
could be null
.
Fixed TODO left from #891 : re-add sweeps to new batches only after fully confirmed.
In case of a reorg sweeps should not go to another batch but stay in the current batch until it is fully confirmed. Only after that the remaining sweeps are re-added to another batch. Field
sweep.completed
is now set to true only for fully-confirmed sweeps.Fixed OnChainFeePortion values. There were two mistakes. In case of a swap with multiple sweeps only the fee of the first sweep of a swap was accounted. Another issue is that rounding diff (the remainder) was attributed to all the sweeps rather than to the first (primary) sweep of the batch. The sweep to attribute the remainder was chosen by comparing SignatureScript which is
always empty. New approach is to find the primary sweep and to compare its outpoint directly.
Pull Request Checklist
release_notes.md
if your PR contains major features, breaking changes or bugfixes