-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add sats_per_byte option to newAccounts cmd #288
Conversation
6ff83df
to
cbb7d14
Compare
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.
Great work on your first Pool PR 💯
Mostly nits and suggestions and one problem on the command line. Other than that looks pretty great!
f5affb9
to
926abf0
Compare
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.
Nice work, LGTM 🎉
Just a few minor nits remaining.
account/manager.go
Outdated
|
||
if feeRate == 0 { | ||
return fmt.Errorf("unable to create transaction for "+ | ||
"account with trader key %x, feeRate should be greater "+ |
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.
nit: wrap at 80 characters. You might need to update your editor's config to use 8 spaces for a tab character instead of just 4 or 2 to match everyone else's view of what 80 characters width is :)
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 wonder if we can use a lint step for this, like lll
or something
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 problem is, some lines we can't really break nicely (for example the config with the tagged struct values). So we'd get a lot of false positives. And adding // nolint:lll
to each of the long lines just makes them even longer 😅
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.
Great work! Changes LGMT 🍔, added a few small nits + the ones Oli already suggested.
account/manager.go
Outdated
|
||
// We calculate the default fee rate that will be used | ||
// for resuming accounts for which we haven't created and broadcast | ||
// a transaction for yet |
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.
nit: not 100% sure but I think there's an extra "for" here.
account/manager.go
Outdated
ctx, int32(DefaultFundingConfTarget), | ||
) | ||
if err != nil { | ||
return fmt.Errorf("unable to estimate default fees for resuming"+ |
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.
nit: add a space at the end after resuming
as otherwise it'll concatenate with the next line. Also I think the error itself could just be: "unable to estimate default fees". I personally like long errors but overall we tend to not overexplain error cases and try to reduce to the actual cause.
rpcserver.go
Outdated
return nil, fmt.Errorf("confirmation target must be " + | ||
"greater than 0") | ||
if req.GetFeeRateSatPerKw() > 0 && req.GetConfTarget() > 0 { | ||
return nil, fmt.Errorf("you must set only one of the sat/vbyte " + |
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.
nit: in the error message I think you wanted to write sats/kw
rpcserver.go
Outdated
"value=%v, conf_target=%v", feeRate, value, confTarget) | ||
|
||
default: | ||
return nil, fmt.Errorf("either sat/vbyte or confirmation target " + |
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.
sats/kw ?
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.
Maybe I'd move the error case from the above if
statement here too as a case.
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.
Let me add another small PR with this fix + adding the same check for expiryHeight
926abf0
to
884533e
Compare
Generally the confirmation target is much less granular than a direct sat/byte due to jumps in the confirmation confidence intervals. Changed the account manager to take the `feeRate` instead of the `confTarget`. The caller will be the one with the responsability of calculating the `freeRate`. If the caller does not provide a value (`freeRate=0`) we will calculate it from the default confTarget (6 blocks).
884533e
to
e502ffd
Compare
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.
LGTM, great work on this PR! 🎉
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.
Two last small nits. Feel free to merge any time.
cmd/pool/account.go
Outdated
if err != nil { | ||
return fmt.Errorf("unable to estimate on-chain fees: "+ | ||
"%v", err) | ||
} | ||
|
||
feeRate := chainfee.SatPerKWeight(resp.MinerFeeRateSatPerKw) | ||
satPerVByte := float64(feeRate.FeePerKVByte()) / 1000 | ||
|
||
feePerKVByte := float64(feeRate.FeePerKVByte()) / 1000 |
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.
nit: we still divide by 1000 so it's feePerVByte
. Meaning, we can just overwrite the value of the existing variable here.
if confTarget < 1 { | ||
return nil, fmt.Errorf("confirmation target must be " + | ||
"greater than 0") | ||
if req.GetFeeRateSatPerKw() > 0 && req.GetConfTarget() > 0 { |
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.
nit: this could just be another case
in the switch
statement below.
e502ffd
to
c90f158
Compare
Add ability to specify raw sat/byte when creating an account
#191