Skip to content

Commit

Permalink
filter by deployer address when listing UTXOs
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed May 29, 2024
1 parent 0f49e9c commit 887ef27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
5 changes: 1 addition & 4 deletions e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
r.Logger.Info("cctx2 outbound tx hash %s", cctx2.GetCurrentOutboundParam().Hash)

r.Logger.Info("******* Second test: BTC -> ERC20ZRC20")
utxos, err := r.BtcRPCClient.ListUnspent()
if err != nil {
panic(err)
}
utxos := r.ListDeployerUTXOs()
r.Logger.Print(fmt.Sprintf("There are %d utxos before SendToTSSFromDeployerWithMemo", len(utxos)))
r.Logger.Info("#utxos %d", len(utxos))
r.Logger.Info("memo address %s", r.ERC20ZRC20Addr)
Expand Down
23 changes: 13 additions & 10 deletions e2e/runner/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ import (

var blockHeaderBTCTimeout = 5 * time.Minute

// DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount
func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash.Hash) {
runner.Logger.Print("⏳ depositing BTC into ZEVM")

// fetch utxos
// ListDeployerUTXOs lists the deployer's UTXOs
func (runner *E2ERunner) ListDeployerUTXOs() []btcjson.ListUnspentResult {
utxos, err := runner.BtcRPCClient.ListUnspentMinMaxAddresses(
1,
9999999,
Expand All @@ -42,6 +39,15 @@ func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash
if err != nil {
panic(err)
}
return utxos
}

// DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount
func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash.Hash) {
runner.Logger.Print("⏳ depositing BTC into ZEVM")

// fetch utxos
utxos := runner.ListDeployerUTXOs()

spendableAmount := 0.0
spendableUTXOs := 0
Expand All @@ -62,7 +68,7 @@ func (runner *E2ERunner) DepositBTCWithAmount(amount float64) (txHash *chainhash
runner.Logger.Info("Now sending two txs to TSS address...")

amount = amount + zetabitcoin.DefaultDepositorFee
txHash, err = runner.SendToTSSFromDeployerToDeposit(
txHash, err := runner.SendToTSSFromDeployerToDeposit(
runner.BTCTSSAddress,
amount,
utxos,
Expand All @@ -87,10 +93,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) {

// fetch utxos
btc := runner.BtcRPCClient
utxos, err := runner.BtcRPCClient.ListUnspent()
if err != nil {
panic(err)
}
utxos := runner.ListDeployerUTXOs()
spendableAmount := 0.0
spendableUTXOs := 0
for _, utxo := range utxos {
Expand Down

0 comments on commit 887ef27

Please sign in to comment.