-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 basic bitcoin signet support #5025
Conversation
I added the prefix as decide on in the spec PR (lightning/bolts#844). |
Rebased. @Roasbeef any particular reason for moving this to 0.14 or just because the dependencies weren't ready yet? |
I'm using google translate so I'm sorry if it's strange English. zpay32/decode.go var netPrefixLength = len(net.Bech32HRPSegwit) + 2 At the time of decoding, if it is tbs, the length will be calculated one less. exmaple bad len(tb) + 2 -> s200 |
Thanks for the input @wakiyamap! Will fix that asap. |
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.
I tried a basic open channel end-to-end test between two local nodes (both connected to a local btcd instance) on the default signet and noticed the funding transaction failed to broadcast:
unmatched backend error: -26: TX rejected: transaction 3a7c4ba762cafe3bfe8db312abde4db5ff200e4d066564f21c00393a7a2d64ab has witness data, but segwit isn't active yet
Segwit is indeed active as I received P2WKH funds from a faucet, so it seems there's an issue with btcd determining whether the deployment is active when using signet's segwit deployment parameters.
DeploymentSegwit: {
BitNumber: 1,
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires.
},
chainreg/chainparams.go
Outdated
// BitcoinSigNetParams contains parameters specific to the signet test network. | ||
var BitcoinSigNetParams = BitcoinNetParams{ | ||
Params: &bitcoinCfg.SigNetParams, | ||
RPCPort: "38334", |
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.
Port should be 38332.
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.
Right. We didn't do the if wallet then 38334 else 38332
dance in btcd
. So had to add a special case in lnd
since we always subtract 2 for bitcoind
.
Thanks for testing this E2E! I figured out what the problem was. Going to fix it in Will be fixed in btcsuite/btcd#1718. |
ddbbb56
to
a6d6f5e
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.
The new dependent btcd PR has been merged now as well.
We don't necessarily need to pull in the dependency as the fix was for running |
Ah didn't realize the new one wasn't strictly dependent, it could be useful for those (if any) who choose to install btcd through |
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.
Small set of changes for such a nice feature! LGTM
config.go
Outdated
str := "%s: Invalid signet challenge, " + | ||
"hex decode failed: %v" | ||
err := fmt.Errorf(str, funcName, err) |
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.
why separate string and error here?
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.
Wanted to follow the style of the rest of the file. But you're right, I like the more compact style more as well, fixed.
With this commit we make lnd compatible with the public signet test network.
The Core devs decided to us the same bech32 HRP for Signet as is used for the current Testnet3. This might be okay for on-chain addresses since they are compatible in theory. But for invoices we want to use a distinct HRP to distinguish testnet from signet. Also see spec PR lightning/bolts#844 for more information about the reasoning.
This commit updates the btcd version to a more recent one in which a bug was fixed that lead to SegWit and Taproot not being activated properly on signet. This update is not strictly necessary for lnd to work but we include it in case anyone wants to install btcd through lnd's Makefile.
I added a commit to bump @Roasbeef, @cfromknecht any chance we can get this in for |
Default rpc port seems to be incorrectly 38330. // works // fails, see log below 2021-05-25 12:53:38.521 [INF] LNWL: Opened wallet unable to create chain control: Post "http://x.x.x.x:38330": dial tcp x.x.x.x:38330: connect: operation timed out |
cc @guggero ^ |
rpcPort = 19443 | ||
case cfg.Bitcoin.Active && cfg.Bitcoin.SigNet: | ||
rpcPort = 38332 |
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.
@vwoo perhaps something is being morphed before the call is made? We enforce the default port here
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.
If I change the signet port from 38332 to 38334 in chainreg/chainparams.go then the default port works.
Just following the pattern in the rest of chainparams.go where the port is always +2.
bitcoind --help | grep rpcport
mainnet: 8332
testnet: 18332
signet: 38332
chainreg/chainparams.go
mainnet: 8334
testnet: 18334
signet: 38332
Seems like the pattern break is intentional but maybe there was a mixup between chainregistry.go and chainparams.go?
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.
Gonna merge as is, AFAICT the port information is correct here. Want to include this in the next rc, and can do another one if it turns out there's actually something afoot here. |
I have nothing special to add here but to say I love that this came in at this time!!! Timely and kudos to everyone involved! |
Fixes #5018.
Depends on btcsuite/btcd#1692.
Depends on btcsuite/btcwallet#735.
Updates to the latest
btcd
version (which is why the diff is that large) and adds basic signet support.