Add bitcoin-units crate#1225
Conversation
ad9dcfc to
5815d99
Compare
5815d99 to
f501fd5
Compare
|
Excuse all the force pushes, I'm wrestling with a few CI things but the core of this PR should be good to go! |
7c06523 to
29c733b
Compare
|
Finally, all green :) |
Kixunil
left a comment
There was a problem hiding this comment.
Mostly nits, what I require is to fix (remove) the doc link and I strongly want to remove core2 dep.
Also maybe make adding the crate and depending on it a single commit so that git would show the file as moved.
29c733b to
6e6eac3
Compare
nits implemented
Still to resolve, commented above.
Done |
6e6eac3 to
79102d4
Compare
|
Done reviewing 79102d447ca9607ab60fa9b50acf2063ab43e111. This looks great! ACK except I'd really like to drop |
37cd650 ci: Remove TOOLCHAIN env var (Tobin C. Harding) 8eb6c23 ci: Remove inner quotes from shell variable (Tobin C. Harding) 58ede47 ci: Use set -ex instead of /bin/sh -ex (Tobin C. Harding) 4c4846f Remove double blank line at EOF (Tobin C. Harding) Pull request description: Clean up the CI script. These patches are part of #1225, are beneficial to have before that PR resolves, and are trivial. ACKs for top commit: sanket1729: utACK 37cd650 apoelstra: ACK 37cd650 Tree-SHA512: f6b3379c8a1be7a3519461faeed35e35560e4228bddb59ef28ab3fb3ef2679afabfaccfeaffd78adbb66879aed02c092f3d9d1d1eb3193c811067ee75e876732
|
I wonder if |
I think so too.
Why's that? Only |
|
Indeed, and not putting |
|
I don't think it'd be too weird if |
79102d4 to
1f6eb92
Compare
|
Hey @Kixunil, I rebased on #1297 (fixed a minor issue in macro) but I couldn't get it to build because a static string cannot be used to create a impl fmt::Display for ParseAmountError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use ParseAmountError::*;
match *self {
...
UnknownDenomination(ref d) => write!(f, "{}", d.display_cannot_parse("denomination")),
... |
Oh, forgot to add Edit: removed the bound. |
Kixunil
left a comment
There was a problem hiding this comment.
ACK f2483a7c25f49f343063b1fd8853023c62b3a9dd
bitcoin/src/lib.rs
Outdated
There was a problem hiding this comment.
I don't see the inline here.
|
Bizzare, the change is in my tree and EDIT: In case you don't see the comment I made elsewhere, my mistake, I had only done it in |
I'm not sure it matters but the https://crates.io/api/v1/crates/bitcoin_hashes/0.13.0/download to download the file, which is a tarball even though it ends in |
f2483a7 to
40f2c7d
Compare
40f2c7d to
e3dab80
Compare
|
Rebased, no other changes. |
|
Used |
|
I've dropped the copy license patch, its unrelated to this PR since we have other crates already without it. (Force push includes fix to rebase fail also.) |
Kixunil
left a comment
There was a problem hiding this comment.
ACK 53fce7ba07be8927a7d66d5b6022f27e8b737b4e
units/Cargo.toml
Outdated
There was a problem hiding this comment.
IIUC the commits before this one didn't support no-alloc and would fail if tested but I think it's OK since the crate was just created here.
There was a problem hiding this comment.
I ran cargo test --all--features in units on commit: f42033da Add ParseDenominationError just to make sure. It passes. The reason is that we only use write_err from internals until we introduce InputString usage, so I believe the features are updated in the correct patches.
There was a problem hiding this comment.
Actually you need to run --no-default-features.
There was a problem hiding this comment.
Still tests cleanly with no default features. Did you see the error or are you guessing from the diff?
There was a problem hiding this comment.
What kind of sorcery is this?! I was judging from the diff because there was no #[cfg] to remove the string where InputString is now. Which means my review wasn't very good and I should look into it better.
There was a problem hiding this comment.
oooo, took me a while to work this out, we have the very sneaky module declaration as:
// TODO: Make amount module less dependent on an allocator.
#[cfg(feature = "alloc")]
pub mod amount;There was a problem hiding this comment.
There is still a bit of work to do to remove that TODO because of all the functions that return String.
|
@apoelstra you've been strangely quite on this PR, is it because it only moves amounts? I was planning on adding other types when it merges and before its released, I have not thought yet about which ones though. |
It's because there were a zilion comments from Kix, then fixes, then repeats. Now that Kix has ACKed I have a TODO to review it. Maybe tomorrow. |
|
Sweet, no stress. |
|
In f42033dadec7d94dbc9c8efbb301e04d70e9f25c, But utACK 53fce7ba07be8927a7d66d5b6022f27e8b737b4e once you get it compiling. |
|
I just used |
Kixunil
left a comment
There was a problem hiding this comment.
ACK 4f7779174ca99fb8bb5970b3f867464f0da64eb2
|
c36f07516e8f49ef7d9140848929795efefe611 has the same issue. |
Add a new crate `bitcoin-units`, move the `amount` module over to it and re-export all types from `bitcoin::amount` so this as not a breaking change.
We have two variants in the `ParseAmountError` that both come from parsing a denomination, these should be a separate error.
Done so that we can correctly support builds without an allocator. Add two new error types that wrap `InputString`.
|
Bother, one day I'll start remembering to pass |
Create a new
bitcoin-unitscrate as described here.Only the
amountmodule is currently included.I've resolved the
Encodale/Decodableissue by keeping theamountmodule inbitcoin.