Skip to content
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

Merged
merged 3 commits into from
Oct 1, 2021
Merged

Conversation

positiveblue
Copy link
Contributor

@positiveblue positiveblue commented Sep 23, 2021

Add ability to specify raw sat/byte when creating an account

#191

@positiveblue positiveblue force-pushed the issue-191 branch 3 times, most recently from 6ff83df to cbb7d14 Compare September 24, 2021 04:15
@positiveblue positiveblue marked this pull request as ready for review September 24, 2021 04:28
Copy link
Member

@guggero guggero left a 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!

account/manager.go Outdated Show resolved Hide resolved
account/manager.go Outdated Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
cmd/pool/account.go Outdated Show resolved Hide resolved
cmd/pool/account.go Outdated Show resolved Hide resolved
cmd/pool/account.go Outdated Show resolved Hide resolved
cmd/pool/account.go Outdated Show resolved Hide resolved
cmd/pool/account.go Outdated Show resolved Hide resolved
@positiveblue positiveblue force-pushed the issue-191 branch 2 times, most recently from f5affb9 to 926abf0 Compare September 26, 2021 01:26
Copy link
Member

@guggero guggero left a 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 Show resolved Hide resolved

if feeRate == 0 {
return fmt.Errorf("unable to create transaction for "+
"account with trader key %x, feeRate should be greater "+
Copy link
Member

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 :)

Copy link
Contributor Author

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

Copy link
Member

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 😅

account/manager.go Outdated Show resolved Hide resolved
rpcserver.go Show resolved Hide resolved
cmd/pool/account.go Outdated Show resolved Hide resolved
cmd/pool/account.go Outdated Show resolved Hide resolved
Copy link
Member

@bhandras bhandras left a 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.


// 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
Copy link
Member

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.

ctx, int32(DefaultFundingConfTarget),
)
if err != nil {
return fmt.Errorf("unable to estimate default fees for resuming"+
Copy link
Member

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 " +
Copy link
Member

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 Show resolved Hide resolved
rpcserver.go Outdated
"value=%v, conf_target=%v", feeRate, value, confTarget)

default:
return nil, fmt.Errorf("either sat/vbyte or confirmation target " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sats/kw ?

Copy link
Member

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.

Copy link
Contributor Author

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

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).
Copy link
Member

@bhandras bhandras left a 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! 🎉

Copy link
Member

@guggero guggero left a 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.

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
Copy link
Member

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 {
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants