Skip to content

Commit

Permalink
cleaned up redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Sep 12, 2023
1 parent 97d372d commit 1effd3e
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64
ob.logger.ObserveOutTx.Warn().Msg("IsSendOutTxProcessed: res.Amount > 0")
amount = res.Amount
} else if res.Amount == 0 {
ob.logger.ObserveOutTx.Error().Msgf("IsSendOutTxProcessed: res.Amount == 0, using original amount %f", amount)
ob.logger.ObserveOutTx.Error().Msg("IsSendOutTxProcessed: res.Amount == 0")
return false, false, nil
} else {
amount = -res.Amount
Expand Down Expand Up @@ -921,32 +921,6 @@ func (ob *BitcoinChainClient) checkTSSVin(vins []btcjson.Vin, nonce uint64) erro
return nil
}

// TODO: develop a well-defined cctx validation in zetacore.
func (ob *BitcoinChainClient) ValidateCctxParams(params *types.OutboundTxParams) error {
// More broadly, we should probably think about the address format that we support
// 1. legacy P2PKH like 2Mz1XjXzgQCxXfazTAmsTAj46dQkmAdK5X2
// 2. segwit P2PKH like tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur, this is what we support for now
// 3. taproot P2PKH?
// 4. other P2SH?

// validate receiver address
addr, err := btcutil.DecodeAddress(params.Receiver, config.BitconNetParams)
if err != nil {
return err
}
_, ok := addr.(*btcutil.AddressWitnessPubKeyHash)
if err != nil || !ok {
return fmt.Errorf("ValidateCctxParams: cannot convert address %s to P2WPKH address", params.Receiver)
}

// validate amount
_, err = getSatoshis(float64(params.Amount.Uint64()) / 1e8)
if err != nil {
return fmt.Errorf("ValidateCctxParams: invalid amount %d", params.Amount)
}
return nil
}

// Vout is valid if:
// - The first output is the nonce-mark
// - The second output is the correct payment to recipient
Expand Down

0 comments on commit 1effd3e

Please sign in to comment.