-
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
lncli: allow openchannel to accept a node's URI #1402
lncli: allow openchannel to accept a node's URI #1402
Conversation
3db01ac
to
3159ff5
Compare
3159ff5
to
bfcaf32
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.
Thanks for the PR! I think a better approach would be to just provide either a node pubkey or a URI without the need for a connect
flag. If we detect a URI, then we can attempt to connect to it before attempting to open the channel. Thoughts?
@wpaulino Thanks for the look. Removing |
I'm on board with removing it, it's a CLI flag so it would only impact those workflows. We usually recommend people to stay pinned to the latest tagged release if they're looking for stability anyway. Will leave the decision to the rest of the team. |
bfcaf32
to
1250593
Compare
I've pushed changes removing |
if err != nil { | ||
return fmt.Errorf("unable to decode node public key: %v", err) | ||
} | ||
nodePubHex, connectVal, err = decodeNodePubkeyOrURI( |
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.
nit: I believe req.NodePubkey
can be used here directly.
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 don't think so given that the first arg (like node_key
above) can either be a pubkey or a URI, and in the latter case we need to unpack it, but maybe I'm missing something.
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.
to clarify, what I meant was the following 😄 Not sure if it works?
switch {
case ctx.IsSet("node_key"):
req.NodePubkey, connectVal, err = decodeNodePubkeyOrURI(
ctx.String("node_key"))
case args.Present():
req.NodePubkey, connectVal, err = decodeNodePubkeyOrURI(
args.First())
args = args.Tail()
default:
return fmt.Errorf("node id argument missing")
}
cmd/lncli/commands.go
Outdated
split := strings.Split(val, "@") | ||
|
||
if len(split) > 1 { | ||
nodeKey, connectVal = split[0], split[1] |
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.
looks like nodeKey
is never set in the case where no URI is given?
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.
D'oh! Good find. Willfix.
I'm in favour of removing |
Removes the `--connect` option. Many websites (recksplorer, lightninggem) advertise their node in terms of URI. Allow `openchannel` to accept a URI (pubkey@host:port) without throwing a decode error, and use the hostname information to attempt a connection.
1250593
to
a8ff6ff
Compare
Pushed changes incorporating @halseth's feedback. |
Tested with both URI and pubkey on mainnet: $ lncli openchannel --sat_per_byte 40 024a2e265cd66066b78a788ae615acdc84b5b0dec9efac36d7ac87513015eaf6ed@lnd.bitrefill.com 9000000 0
{
"funding_txid": "3fb66e74b8ece13eebf883d9d210adacc9390bcdd446c580bde59ffc80ab342d"
}
$ lncli openchannel --sat_per_byte 40 03e50492eab4107a773141bb419e107bda3de3d55652e6e1a41225f06a0bbf2d56 2000000 0
{
"funding_txid": "eb7a1c1d7719131e1756b552564886355cbb83ae749afb7a98fc866cbc6608ed"
} |
Needs a rebase! |
Many websites (recksplorer, lightninggem) advertise their node in terms of URI.
Allow
lncli openchannel
to accept a URI (pubkey@host:port) without throwing adecode error, and use the hostname information to attempt a connection without
having to specify
--connect
.This removes
--connect
as it is no longer needed.Example usage