Skip to content

Commit

Permalink
Include extra data of deposits for sweep fee estimation
Browse files Browse the repository at this point in the history
Bitcoin scripts of deposits embedding 32-byte extra data are longer (126 bytes)
than the scripts of regular deposits not holding extra data (92 bytes).
That means the actual virtual size of the resulting deposit sweep transaction
is greater than the size assumed by the sweep fee estimator. Here we adjust the
fee estimator to always take the longer script for calculations to avoid
underestimation of the transaction fee. This approach is not ideal but
is safe as it makes sure transactions are not rejected due to too low network
fees.
  • Loading branch information
lukasz-zimnoch committed Jan 25, 2024
1 parent bc8c1f0 commit 2bf630d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/tbtcpg/deposit_sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/keep-network/keep-core/pkg/tbtc"
)

const depositScriptByteSize = 92
// Use the worst-case 126-byte deposit script with embedded extra data for estimation.
// This will ensure that deposit sweep transaction fees are not underestimated.
const depositScriptByteSize = 126

// DepositSweepTask is a task that may produce a deposit sweep proposal.
type DepositSweepTask struct {
Expand Down

0 comments on commit 2bf630d

Please sign in to comment.