docs: add amount example for units crate#43
docs: add amount example for units crate#43Zeegaths wants to merge 1 commit intorust-bitcoin:masterfrom
Conversation
|
Overall this looks amazing, thanks! I just commented a few nits. |
1ede28e to
e1c8a0c
Compare
Thanks for this! made the changes. I could pick up the rest of the docs? |
|
Thanks for the contribution.
I'll review quite heavily then so that it saves you time on the next ones. |
| @@ -0,0 +1,168 @@ | |||
| # Amount | |||
|
|
|||
| In this section, we will demonstrate different ways of working with Bitcoin amounts using the `Amount` type. The examples in this section will: | |||
There was a problem hiding this comment.
I think we should try to use little 'b' for the currency and big 'B' for the network.
cookbook/src/units/amount.md
Outdated
| let large = Amount::from_sat(100_000_000).expect("valid amount"); | ||
| println!("Large Amount = {}", large); | ||
|
|
||
| // Parsing string type to Amount - result handling needed for potential error |
There was a problem hiding this comment.
Everything that is code needs back ticks. Here Amount and a bunch of function names elsewhere.
cookbook/src/units.md
Outdated
| @@ -0,0 +1,21 @@ | |||
| Bitcoin is majorly expressed as BTC(bitcoins), mBTC(millibitcoins), sats(satoshis) or bits. | |||
There was a problem hiding this comment.
I'm not keen on this line. Because of the wording: 'majorly express in'. But I rekon better to just mention sats and BTC, but that could be subjective.
There was a problem hiding this comment.
I think "usually expressed in" is more idiomotic English.
BTW, these weird expressions make me think this is not LLM output. Though I agree that it often explains things that are too basic to be worth explaining.
cookbook/src/units.md
Outdated
|
|
||
| The satoshi, named after the original bitcoin creator, Satoshi Nakamoto, is the smallest unit of bitcoin currency representing a hundred millionth of one Bitcoin (0.00000001 BTC). | ||
|
|
||
| The Bitcoin source code uses satoshi to specify any Bitcoin amount and all amounts on the blockchain are denominated in satoshi before they get converted for display. |
There was a problem hiding this comment.
Are we documenting the protocol or the rust-bitcoin lib, its not obvious to me from some of these docs which direction we are going in?
There was a problem hiding this comment.
I kinda liked these two sentences. Yes, they're "off-topic" in that they're about the protocol rather than this library, but they're useful context for why we have such a weird and large API for Amount.
There was a problem hiding this comment.
I'll cut out some of the fluff
|
Sigh. Guess you were right @tcharding I wonder if it makes sense to move this repo to Forgejo....we hadn't really considered stopping hosting rust-bitcoin.org on Github. On the one hand, self-hosting a website is pretty-much the easiest thing we can do. On the other hand it's still kinda a PITA. |
|
I put an ernest 20 minutes at least into reviewing this yesterday for it just to be closed. I am getting close to not wanting to review PRs from external contributors, which is a bit sad really. |
Sorry for closing prematurely, I've addressed all the feedback. |
e1c8a0c to
273d971
Compare
Add cookbook entry for
Amountcovering the "Amount" section from #4694.What it covers:
MAX,ONE_BTC,ONE_SAT,ZERO,FIFTY_BTC)from_sat_u32andfrom_satparsedisplay_in,display_dynamic, and thealloc-gated string methodsNumOpResultusage with arithmetic and underflow handlingCloses the "Amount" section of #4694.