Skip to content

Commit

Permalink
print a few logs to debug fees and make sure gasPrice get increased a…
Browse files Browse the repository at this point in the history
…t least by 1 sat per byte
  • Loading branch information
ws4charlie committed Nov 2, 2023
1 parent 6e1fb4a commit c954ead
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions zetaclient/btc_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down

0 comments on commit c954ead

Please sign in to comment.