Skip to content

Commit

Permalink
Include extra data of deposits for sweep fee estimation (#3766)
Browse files Browse the repository at this point in the history
Refs: keep-network/tbtc-v2#749

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
tomaszslabon committed Jan 25, 2024
2 parents bc8c1f0 + 29d4b44 commit 843f021
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"FundingOutputIndex": 3
}
],
"SweepTxFee": 9984,
"SweepTxFee": 10634,
"DepositsRevealBlocks": [11, 31, 32]
}
}

0 comments on commit 843f021

Please sign in to comment.