-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Estimate redemption transaction fee during proposal #3651
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment. Other than that, looks good.
pkg/coordinator/redemptions.go
Outdated
case bitcoin.P2WSHScript: | ||
sizeEstimator.AddScriptHashOutputs(1, true) | ||
default: | ||
panic("non-standard redeemer output script type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if we should trust the contract validation that much. We can have an upgrade and change the on-chain logic. I think it is OK to assume the script has to be one of the four types listed before but if it is not I would rather return an error, log it, and decide not to propose a redemption instead of killing the process.
At some point in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main purpose of this panic is to signal that something changed on the contract side and requires our attention. I'm afraid that returning an error and just logging it may not be visible enough. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the client should panic only if there is no way out. Here there is a way out - we can decide not to propose a redemption and eventually, we can even skip the given script when proposing the redemption. Agreed about calling the attention but I would address it somewhere else, e.g. have a script type for every redemption request at tbtcscan.com
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See dc866e4
Refs #3614
Here we add a function allowing us to estimate the redemption transaction total fee (
coordinator.EstimateRedemptionFee
) and we integrate it with the existingcoordinator.ProposeRedemption
function.