From fc5d55e35a5465ec537550b64dd1cc49292e90fc Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 7 Mar 2024 12:01:16 +0100 Subject: [PATCH] Prevented moving funds if there are unswept deposits --- pkg/tbtcpg/moving_funds.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/tbtcpg/moving_funds.go b/pkg/tbtcpg/moving_funds.go index 31d9c8ae80..32425d236c 100644 --- a/pkg/tbtcpg/moving_funds.go +++ b/pkg/tbtcpg/moving_funds.go @@ -103,6 +103,27 @@ func (mft *MovingFundsTask) Run(request *tbtc.CoordinationProposalRequest) ( return nil, false, nil } + // The wallet should not have any unswept deposits. + unsweptDeposits, err := FindDeposits( + mft.chain, + mft.btcChain, + walletPublicKeyHash, + 0, + true, + true, + ) + if err != nil { + return nil, false, fmt.Errorf( + "cannot check wallet's unswept deposits: [%w]", + err, + ) + } + + if len(unsweptDeposits) > 0 { + taskLogger.Infof("source wallet has unswept deposits") + return nil, false, nil + } + walletMainUtxo, err := tbtc.DetermineWalletMainUtxo( walletPublicKeyHash, mft.chain,