From c954eadb862b2856e7a62223d53509e65f4845cd Mon Sep 17 00:00:00 2001 From: charliec Date: Wed, 1 Nov 2023 20:00:02 -0500 Subject: [PATCH] print a few logs to debug fees and make sure gasPrice get increased at least by 1 sat per byte --- zetaclient/btc_signer.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zetaclient/btc_signer.go b/zetaclient/btc_signer.go index 8f131f5814..ffc365fdff 100644 --- a/zetaclient/btc_signer.go +++ b/zetaclient/btc_signer.go @@ -274,7 +274,7 @@ func (signer *BTCSigner) TryProcessOutTx(send *types.CrossChainTx, outTxMan *Out sizelimit := params.OutboundTxGasLimit gasprice, ok := new(big.Int).SetString(params.OutboundTxGasPrice, 10) - if !ok || gasprice.Cmp(big.NewInt(0)) < 0 { + if !ok || gasprice.Cmp(big.NewInt(0)) <= 0 { logger.Error().Msgf("cannot convert gas price %s ", params.OutboundTxGasPrice) return } @@ -295,9 +295,15 @@ func (signer *BTCSigner) TryProcessOutTx(send *types.CrossChainTx, outTxMan *Out networkInfo, err := signer.rpcClient.GetNetworkInfo() if err != nil { logger.Error().Err(err).Msgf("cannot get bitcoin network info") + } else { + satPerByte := feeRateToSatPerByte(networkInfo.RelayFee) + if satPerByte.Cmp(big.NewInt(0)) == 0 { + logger.Info().Msgf("relayFee is less than 1 sat/byte; use 1 sat/byte") + satPerByte = big.NewInt(1) + } + logger.Info().Msgf("increase gasprice %s by %s, relayFee %f", gasprice.String(), satPerByte.String(), networkInfo.RelayFee) + gasprice.Add(gasprice, satPerByte) } - satPerByte := feeRateToSatPerByte(networkInfo.RelayFee) - gasprice.Add(gasprice, satPerByte) logger.Info().Msgf("SignWithdrawTx: to %s, value %d sats", addr.EncodeAddress(), params.Amount.Uint64()) logger.Info().Msgf("using utxos: %v", btcClient.utxos)