Skip to content

Commit

Permalink
Added moving funds commitment submission
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Nov 28, 2023
1 parent 83a0779 commit 4a9ec3c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
22 changes: 22 additions & 0 deletions pkg/chain/ethereum/tbtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,28 @@ func (tc *TbtcChain) OnMovingFundsCommitmentInitiated(handler func(uint64)) subs
})
}

func (tc *TbtcChain) SubmitMovingFundsCommitment(
walletPublicKeyHash [20]byte,
walletMainUTXO bitcoin.UnspentTransactionOutput,
walletMembersIDs []uint32,
walletMemberIndex uint32,
targetWallets [][20]byte,
) error {
mainUtxo := tbtcabi.BitcoinTxUTXO{
TxHash: walletMainUTXO.Outpoint.TransactionHash,
TxOutputIndex: walletMainUTXO.Outpoint.OutputIndex,
TxOutputValue: uint64(walletMainUTXO.Value),
}
_, err := tc.bridge.SubmitMovingFundsCommitment(
walletPublicKeyHash,
mainUtxo,
walletMembersIDs,
big.NewInt(int64(walletMemberIndex)),
targetWallets,
)
return err
}

func (tc *TbtcChain) ValidateRedemptionProposal(
proposal *tbtc.RedemptionProposal,
) error {
Expand Down
15 changes: 14 additions & 1 deletion pkg/tbtc/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,20 @@ type WalletCoordinatorChain interface {
func(event *RedemptionProposalSubmittedEvent),
) subscription.EventSubscription

OnMovingFundsCommitmentInitiated(func(blockNumber uint64)) subscription.EventSubscription
// OnMovingFundsCommitmentInitiated registers a callback that is invoked
// when moving funds commitment is initiated.
OnMovingFundsCommitmentInitiated(
func(blockNumber uint64),
) subscription.EventSubscription

// Submits the moving funds target wallets commitment.
SubmitMovingFundsCommitment(
walletPublicKeyHash [20]byte,
walletMainUTXO bitcoin.UnspentTransactionOutput,
walletMembersIDs []uint32,
walletMemberIndex uint32,
targetWallets [][20]byte,
) error

// ValidateDepositSweepProposal validates the given deposit sweep proposal
// against the chain. It requires some additional data about the deposits
Expand Down
10 changes: 10 additions & 0 deletions pkg/tbtc/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,16 @@ func (lc *localChain) OnMovingFundsCommitmentInitiated(handler func(uint64)) sub
panic("unsupported")
}

func (lc *localChain) SubmitMovingFundsCommitment(
walletPublicKeyHash [20]byte,
walletMainUTXO bitcoin.UnspentTransactionOutput,
walletMembersIDs []uint32,
walletMemberIndex uint32,
targetWallets [][20]byte,
) error {
panic("unsupported")
}

func (lc *localChain) ValidateRedemptionProposal(
proposal *RedemptionProposal,
) error {
Expand Down

0 comments on commit 4a9ec3c

Please sign in to comment.