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

btcutil: format BTC amounts with trailing zeroes #1996

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

C-Otto
Copy link
Contributor

@C-Otto C-Otto commented Jun 18, 2023

so that sat amounts can be read without counting zeroes

before:

 350sat = 0.0000035 BTC
3500sat = 0.000035 BTC

after:

 350sat = 0.00000350 BTC
3500sat = 0.00003500 BTC

fixes #1995

@C-Otto C-Otto force-pushed the trailing-zeroes branch from 48cdfb8 to b3bf800 Compare June 18, 2023 08:30
Copy link
Collaborator

@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.

Thanks for the change, this has bugged me before as well.
Can be simplified quite a bit IMO.

btcutil/amount.go Outdated Show resolved Hide resolved
btcutil/amount.go Outdated Show resolved Hide resolved
btcutil/amount.go Outdated Show resolved Hide resolved
@C-Otto
Copy link
Contributor Author

C-Otto commented Jun 19, 2023

Thanks, that's Go code written by a Java programmer :) I'll tidy it up!

@C-Otto C-Otto force-pushed the trailing-zeroes branch from b3bf800 to 35b3975 Compare June 19, 2023 15:52
@C-Otto C-Otto requested a review from guggero June 19, 2023 15:56
Copy link
Collaborator

@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.

Thanks, LGTM 🎉

@coveralls
Copy link

coveralls commented Jun 19, 2023

Pull Request Test Coverage Report for Build 5456779174

  • 9 of 9 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 55.258%

Totals Coverage Status
Change from base Build 5415736563: 0.02%
Covered Lines: 26703
Relevant Lines: 48324

💛 - Coveralls

Copy link
Collaborator

@halseth halseth left a comment

Choose a reason for hiding this comment

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

Code change ack, but could we accidentally break any code parsing these strings?

btcutil/amount_test.go Show resolved Hide resolved
so that sat amounts can be read without counting zeroes

before:
 350sat = 0.0000035 BTC
3500sat = 0.000035 BTC

after:
 350sat = 0.00000350 BTC
3500sat = 0.00003500 BTC

fixes btcsuite#1995
@C-Otto
Copy link
Contributor Author

C-Otto commented Jul 4, 2023

Yes, code parsing this might be affected. We're not changing the amount and 1.5 = 1.50, so it shouldn't cause massive headaches. It's a risk, though, and I'm not in a position to decide for or against this.

@C-Otto C-Otto force-pushed the trailing-zeroes branch from 35b3975 to 725b36b Compare July 4, 2023 16:20
@guggero
Copy link
Collaborator

guggero commented Jul 10, 2023

cc @Roasbeef

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 📸

@Roasbeef Roasbeef merged commit 4933e35 into btcsuite:master Jul 10, 2023
@C-Otto C-Otto deleted the trailing-zeroes branch July 20, 2023 06:42
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.

BTC amounts show trailing zeroes
5 participants