keep-network / keep-core

The smart contracts and reference client behind the Keep network
https://keep.network
MIT License
118 stars 73 forks source link

Moving funds commitment implementation #3748

Closed tomaszslabon closed 6 months ago

tomaszslabon commented 9 months ago

Refs: https://github.com/keep-network/keep-core/issues/3733.

This PR introduces functionalities that enable a wallet to submit a moving funds commitment. These functionalities have been incorporated into the tbtcpg package through the creation and execution of a MovingFundsTask. They were implemented in the same manner as other procedures such as deposit sweeps and redemptions.

The task results in a moving funds proposal, which is needed for generating the Bitcoin transaction that transfer funds between wallets. Usually, this process will also involve submitting the moving funds commitment transaction to the Bridge. This submission step may be skipped if the commitment has already been submitted, which can occur if a previously initiated moving funds procedure was interrupted post-commitment submission and still needs completion.

Executing a moving funds task consists of several key steps: 1) Verifying the eligibility of the wallet for moving funds, involving checks on the wallet's state and balance. 2) Preparing the target wallets, which includes either creating a new list of wallets or retrieving an existing list from a previous, interrupted moving funds procedure. 3) Submitting the moving funds transaction to the Bridge, unless it has already been submitted. 4) Creating and validating the moving funds proposal, a process that involves estimating the Bitcoin transaction fee.

Upon completion of the moving funds task, all necessary prerequisites for the Bitcoin moving funds transaction should be satisfied.