Skip to content
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

wallet: RBF batch payments manager #9298

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

Conversation

ecdsa
Copy link
Member

@ecdsa ecdsa commented Nov 12, 2024

note: this is not "reorg safe", meaning that there is no guarantee that all payments will end up in in the blockchain.
However, I believe this is "double send safe", meaning that we will never send a payment twice.

@ecdsa ecdsa marked this pull request as ready for review November 12, 2024 10:20
@ecdsa ecdsa force-pushed the batch_payments_manager branch from b71b11f to 45c7543 Compare November 14, 2024 09:21
@ecdsa ecdsa force-pushed the batch_payments_manager branch 13 times, most recently from a48e7ca to 5c7a247 Compare December 4, 2024 10:34
@ecdsa ecdsa added this to the 4.6.0 milestone Dec 4, 2024
@ecdsa ecdsa force-pushed the batch_payments_manager branch 13 times, most recently from 3bdbf87 to 3ad4406 Compare December 10, 2024 09:24
@ecdsa ecdsa force-pushed the batch_payments_manager branch 4 times, most recently from 4a623fe to 0f27755 Compare December 18, 2024 08:06
@ecdsa ecdsa force-pushed the batch_payments_manager branch 4 times, most recently from c065b4a to 689d93e Compare January 3, 2025 12:48
Copy link
Member

@SomberNight SomberNight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some preliminary comments

cls.sign_tx(tx, swap)
return tx
self.add_txin_info(swap, txin)
txin.privkey = swap.privkey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this field used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see sign_transaction in wallet.py

outputs=outputs,
password=password,
locktime=locktime,
BIP69_sort=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why disable bip69 sort?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when sweeping htlc outputs with sighash single-anyonecanpay, the order must be preserved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, the input-output pairings need to be kept for those.
we should have a unit test that would fail if this was set to True

self.config.FEE_EST_DYNAMIC = False
self.config.FEE_EST_STATIC_FEERATE = 1000

def test_claim_tx_for_successful_reverse_swap(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete these tests?
Just because SwapManager._create_and_sign_claim_tx is being removed?

The tests could be adapted to test create_claim_txin instead. Maybe feed the txin to wallet.create_transaction along with some hardcoded values.
The point is to test that the txin is constructed correctly, but the easiest way of doing that is comparing a full tx.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is to test that the txin is constructed correctly, but the easiest way of doing that is comparing a full tx.

Creating a full tx in order to check the construction of a tx input is indeed the easiest way, but it is completely overkill.
I think we should try to put a little bit more efforts in writing tests.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RELEASE-NOTES

# To make payments reorg-safe, we would need to persist more data and redo failed payments.


class TxEngine(Logger):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put "RBF" or "batch" into the name? E.g. I find "RBFEngine" or "TxBatcher" more intuitive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok let's call it TxBatcher

outputs=outputs,
password=password,
locktime=locktime,
BIP69_sort=False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, the input-output pairings need to be kept for those.
we should have a unit test that would fail if this was set to True

@ecdsa ecdsa force-pushed the batch_payments_manager branch 8 times, most recently from b706662 to 22b3527 Compare January 16, 2025 08:25
ecdsa added 10 commits January 16, 2025 09:51
 - delegate tx creation/broadcast to the wallet
 - callers use add_payment_output and add_sweep_input

tests:
 - remove test_sswap.py: cannot be tested that way anymore
 - force regtests to use MPP, so that we sweep transactions with
   several HTLCs. This forces the payment manager to aggregate
   HTLC tx inputs.
- use separate pools,
- fix future tx
 - if coin control is active, disable batching
 - forward submarine swaps can be batched
@ecdsa ecdsa force-pushed the batch_payments_manager branch from 9691a83 to 7a40399 Compare January 16, 2025 08:52
@ecdsa ecdsa marked this pull request as draft January 16, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants