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 signet support #291
add signet support #291
Conversation
FWIW, #255 removed our dependency on rust-bech32-bitcoin but is blocked on a bech32 PR, but that should land soon. |
Getting bitcoin_constants in would make this a lot nicer. It would also solve the problem I have with having to duplicate a lot of code for Elements and Liquid. |
@stevenroose Yeah I noticed a lot of duplicate code all over the place. Wasn't sure what that was about but hopefully it can be reduced. :) I am gonna leave the bech32 PR for now, even if it is not going to relate to this repo specifically in the end. |
Yeah #255 looks good and should allow us to narrow dependency scope for some projects. I believe we're closing in on rust-bitcoin/rest-bech32#35. |
5be1545
to
973936a
Compare
19b0295
to
ed1fb0a
Compare
Codecov Report
@@ Coverage Diff @@
## master #291 +/- ##
=========================================
- Coverage 85.81% 85.7% -0.12%
=========================================
Files 40 40
Lines 7461 7752 +291
=========================================
+ Hits 6403 6644 +241
- Misses 1058 1108 +50
Continue to review full report at Codecov.
|
@kallewoof I'd be happy to review after rebase |
ed1fb0a
to
6e6a02c
Compare
@dongcarl I didn't realize it was in need of a rebase until you nudged, thanks. I think I've rebased it and it works, but my account is flagged at Travis right now so I don't think that CI will ever finish.. |
6e6a02c
to
a721117
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.
- Checked compilation and tests on
1.22.0
,stable
, andnightly
- Checked that all previous mentions of
Network::Regtest
are now also accompanied by a corresponding change addingNetwork::Signet
- Checked all parameters against implementation at https://github.com/kallewoof/bitcoin/blob/2b9db9ac0936cf278ad27c59497d9feec61f6440
I believe we only need to complete the TODO
before this is usable?
src/blockdata/constants.rs
Outdated
merkle_root: txdata[0].txid(), | ||
time: 1534313275, | ||
bits: 0x1e2adc28, | ||
nonce: 621297 |
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.
Note to reviewers: you can verify the time
, bits
, and nonce
parameters by checking:
and
We need to make sure that, before merging, there's some way of passing in the blockscript and creating the Coinbase signature like so:
src/consensus/params.rs
Outdated
0x62a429192f9e8ce5u64, | ||
0xc63b5f100aa5d8dfu64, | ||
0x3c82faa55d83e40au64, | ||
0x00002adc28cf53b6u64, |
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.
These parameters can be verified here: https://github.com/kallewoof/bitcoin/blob/2b9db9ac0936cf278ad27c59497d9feec61f6440/src/chainparams.cpp#L306
src/network/constants.rs
Outdated
@@ -94,6 +97,7 @@ impl Network { | |||
match *self { | |||
Network::Bitcoin => 0xD9B4BEF9, | |||
Network::Testnet => 0x0709110B, | |||
Network::Signet => 0x6A70C7F0, |
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.
src/util/key.rs
Outdated
@@ -128,6 +128,7 @@ impl PrivateKey { | |||
let mut ret = [0; 34]; | |||
ret[0] = match self.network { | |||
Network::Bitcoin => 128, | |||
Network::Signet => 217, |
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.
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.
You forgot to also add the parsing logic for this in the from_wif
method.
src/util/address.rs
Outdated
@@ -370,6 +370,7 @@ impl Display for Address { | |||
let mut prefixed = [0; 21]; | |||
prefixed[0] = match self.network { | |||
Network::Bitcoin => 0, | |||
Network::Signet => 125, |
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.
Changes in this file verifiable here: https://github.com/kallewoof/bitcoin/blob/2b9db9ac0936cf278ad27c59497d9feec61f6440/src/chainparams.cpp#L334-L340
Kicking Travis! |
425446c
to
1c03850
Compare
43a5912
to
1c03850
Compare
Why is it closed? |
@dr-orlovsky Nobody has looked at it for 5 months. Maybe after signet is merged into core it will have more interest. |
Well, I do need it in rust-bitcoin... Probably I will integrate it into my develop branch directly at this stage. |
I actually didn't realize I can't reopen PRs I close on my own, but in either case, I do intend to make a PR, and I will maintain this branch so feel free to use it! If you need help don't hesitate to ping me btw. I'd love to see what you're working on. |
@stevenroose good catch! Added Signet case. |
Edit: the travis error is unrelated to this PR. See #431. |
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
ee3c88d
to
6e66784
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.
Idk if the changes are exhaustive, but the code that is there looks good. ACK from me.
e1aa35d
to
85d7e0c
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.
One test fails + needs rebase with a small conflict in one comment
85d7e0c
to
a3d9899
Compare
Thanks for the nudge. Rebased and fixed genesis nonce/bits/timestamp. |
tACK a3d9899 |
Not sure however how it matches information found in ElementsProject/lightning#2972 about that the new genesis signet nonce is 621297 |
@dr-orlovsky Yeah, well noted. The nonce and such unfortunately changed when we nudged the POW limit awhile ago. I haven't done a re-request to the lightning project with an update yet. |
@kallewoof: c-Lightning version PR with fix: ElementsProject/lightning#4068 |
Signet got merged into Bitcoin Core master: bitcoin/bitcoin#18267 (comment) Let's merge this PR as well - and unblock downstream Electrs dependency: romanz/electrs#239 |
Any ideas on how to push this forward? Should I nudge someone, or just sit tight? Who/where if the former? |
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.
Verified all the constants against bitcoin core, they all match except bip16_time
which I couldn't figure out what is the equivalent in bitcoin core
Thanks, @elichai! I think the bip16_time is only relevant during main net IBD, due to that one offending block, which does not exist in signet, so as long as it's not in the future, it should be fine with any value, I think. |
Add combine_keys function to PublicKey
This PR adds the "signet" network type to the list of networks.
See also: