-
Notifications
You must be signed in to change notification settings - Fork 995
External wallet funding #2672
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
Merged
rustyrussell
merged 20 commits into
ElementsProject:master
from
niftynei:nifty/external-wallet
Jun 12, 2019
Merged
External wallet funding #2672
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1c05996
common: pull out scriptPubkey address method
niftynei c2193c8
json: correct error message for param parser
niftynei 34e1ae3
tests: default all addresses to bech32
niftynei 6735e8e
openingd: allow funding_failed to complete successfully
niftynei 726a757
opening: add entry point for `funding_start rpc command
niftynei f170db9
openingd: pull out setup funder checks into separate method
niftynei 9978782
opening: wire up walking through open channel up thru accept
niftynei aa4533b
pylightning: add fundchannel_start
niftynei d2d2b25
openingd: update billboard with funding info
niftynei c403ee8
opening: stash amount outside of the wtx
niftynei ac06997
lightningd: add start for fundchannel_continue
niftynei 7714520
test: add initial tests for starting an external fundchannel
niftynei ecf3fce
fundchannel: add txout field to RPC/API
niftynei 0db2e41
funding: add a 'inflight' marker
niftynei 29df470
funding: wire up funding_continue
niftynei 1fa147b
opening: add fundchannel_cancel command
niftynei f560aa7
tests: finish up test for external funding flow
niftynei 4f489cf
funding: rename fundchannel_continue -> _complete
niftynei cf66355
funding: update CHANGELOG with new RPC calls
niftynei dcab321
doc: add manpages for fundchannel_[start,complete,cancel]
niftynei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| COMMON_SRC_NOGEN := \ | ||
| common/addr.c \ | ||
| common/amount.c \ | ||
| common/base32.c \ | ||
| common/bech32.c \ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #include "addr.h" | ||
| #include <bitcoin/script.h> | ||
| #include <common/bech32.h> | ||
|
|
||
| /* Returns NULL if the script is not a P2WPKH or P2WSH */ | ||
| char *encode_scriptpubkey_to_addr(const tal_t *ctx, | ||
| const char *hrp, | ||
| const u8 *scriptPubkey) | ||
| { | ||
| char *out; | ||
| size_t scriptLen = tal_bytelen(scriptPubkey); | ||
|
|
||
| /* Check that scriptPubkey is P2WSH or P2WPKH */ | ||
| if (!is_p2wsh(scriptPubkey, NULL) && !is_p2wpkh(scriptPubkey, NULL)) | ||
| return NULL; | ||
|
|
||
| out = tal_arr(ctx, char, 73 + strlen(hrp)); | ||
| if (!segwit_addr_encode(out, hrp, 0, scriptPubkey + 2, scriptLen - 2)) | ||
| return tal_free(out); | ||
|
|
||
| return out; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #ifndef LIGHTNING_COMMON_ADDR_H | ||
| #define LIGHTNING_COMMON_ADDR_H | ||
| #include "config.h" | ||
| #include <ccan/short_types/short_types.h> | ||
| #include <ccan/tal/tal.h> | ||
|
|
||
| /* Given a P2WSH or P2WPKH scriptPubkey, return a bech32 encoded address */ | ||
| char *encode_scriptpubkey_to_addr(const tal_t *ctx, | ||
| const char *hrp, | ||
| const u8 *scriptPubkey); | ||
|
|
||
| #endif /* LIGHTNING_COMMON_ADDR_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| '\" t | ||
| .\" Title: lightning-fundchannel_cancel | ||
| .\" Author: [see the "AUTHOR" section] | ||
| .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> | ||
| .\" Date: 06/05/2019 | ||
| .\" Manual: \ \& | ||
| .\" Source: \ \& | ||
| .\" Language: English | ||
| .\" | ||
| .TH "LIGHTNING\-FUNDCHANN" "7" "06/05/2019" "\ \&" "\ \&" | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * Define some portability stuff | ||
| .\" ----------------------------------------------------------------- | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .\" http://bugs.debian.org/507673 | ||
| .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .ie \n(.g .ds Aq \(aq | ||
| .el .ds Aq ' | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * set default formatting | ||
| .\" ----------------------------------------------------------------- | ||
| .\" disable hyphenation | ||
| .nh | ||
| .\" disable justification (adjust text to left margin only) | ||
| .ad l | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * MAIN CONTENT STARTS HERE * | ||
| .\" ----------------------------------------------------------------- | ||
| .SH "NAME" | ||
| lightning-fundchannel_cancel \- Command for completing channel establishment | ||
| .SH "SYNOPSIS" | ||
| .sp | ||
| \fBfundchannel_cancel\fR \fIid\fR | ||
| .SH "DESCRIPTION" | ||
| .sp | ||
| fundchannel_cancel is a lower level RPC command\&. It allows a user to cancel an initiated channel establishment with a connected peer\&. | ||
| .sp | ||
| \fIid\fR is the node id of the remote peer with which to cancel the | ||
| .SH "RETURN VALUE" | ||
| .sp | ||
| On success, returns confirmation that the channel establishment has been canceled\&. | ||
| .sp | ||
| On failure, returns an error\&. | ||
| .SH "AUTHOR" | ||
| .sp | ||
| Lisa Neigut <niftynei@gmail\&.com> is mainly responsible\&. | ||
| .SH "SEE ALSO" | ||
| .sp | ||
| lightning\-connect(7), lightning\-fundchannel(7), lightning\-fundchannel_start(7), lightning\-fundchannel_complete(7) | ||
| .SH "RESOURCES" | ||
| .sp | ||
| Main web site: https://github\&.com/ElementsProject/lightning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| LIGHTNING-FUNDCHANNEL_CANCEL(7) | ||
| =============================== | ||
| :doctype: manpage | ||
|
|
||
| NAME | ||
| ---- | ||
| lightning-fundchannel_cancel - Command for completing channel establishment | ||
|
|
||
| SYNOPSIS | ||
| -------- | ||
| *fundchannel_cancel* 'id' | ||
|
|
||
| DESCRIPTION | ||
| ----------- | ||
| `fundchannel_cancel` is a lower level RPC command. It allows a user to cancel an initiated | ||
| channel establishment with a connected peer. | ||
|
|
||
| 'id' is the node id of the remote peer with which to cancel the | ||
|
|
||
| RETURN VALUE | ||
| ------------ | ||
| On success, returns confirmation that the channel establishment has been canceled. | ||
|
|
||
| On failure, returns an error. | ||
|
|
||
| AUTHOR | ||
| ------ | ||
| Lisa Neigut <niftynei@gmail.com> is mainly responsible. | ||
|
|
||
| SEE ALSO | ||
| -------- | ||
| lightning-connect(7), lightning-fundchannel(7), lightning-fundchannel_start(7), | ||
| lightning-fundchannel_complete(7) | ||
|
|
||
| RESOURCES | ||
| --------- | ||
| Main web site: https://github.com/ElementsProject/lightning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| '\" t | ||
| .\" Title: lightning-fundchannel_complete | ||
| .\" Author: [see the "AUTHOR" section] | ||
| .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> | ||
| .\" Date: 06/05/2019 | ||
| .\" Manual: \ \& | ||
| .\" Source: \ \& | ||
| .\" Language: English | ||
| .\" | ||
| .TH "LIGHTNING\-FUNDCHANN" "7" "06/05/2019" "\ \&" "\ \&" | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * Define some portability stuff | ||
| .\" ----------------------------------------------------------------- | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .\" http://bugs.debian.org/507673 | ||
| .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .ie \n(.g .ds Aq \(aq | ||
| .el .ds Aq ' | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * set default formatting | ||
| .\" ----------------------------------------------------------------- | ||
| .\" disable hyphenation | ||
| .nh | ||
| .\" disable justification (adjust text to left margin only) | ||
| .ad l | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * MAIN CONTENT STARTS HERE * | ||
| .\" ----------------------------------------------------------------- | ||
| .SH "NAME" | ||
| lightning-fundchannel_complete \- Command for completing channel establishment | ||
| .SH "SYNOPSIS" | ||
| .sp | ||
| \fBfundchannel_complete\fR \fIid\fR \fItxid\fR \fItxout\fR | ||
| .SH "DESCRIPTION" | ||
| .sp | ||
| fundchannel_complete is a lower level RPC command\&. It allows a user to complete an initiated channel establishment with a connected peer | ||
| .sp | ||
| \fIid\fR is the node id of the remote peer | ||
| .sp | ||
| \fItxid\fR is the hex string of the funding transaction id\&. | ||
| .sp | ||
| \fItxout\fR is the integer outpoint of the funding output for this channel\&. | ||
| .sp | ||
| Note that the funding transaction should not be broadcast until after channel establishment has been successfully completed, as the commitment transactions for this channel are not secured until this command succesfully completes\&. | ||
| .SH "RETURN VALUE" | ||
| .sp | ||
| On success, returns a confirmation that \fIcommitments_secured\fR and the derived \fIchannel_id\fR\&. | ||
| .sp | ||
| On failure, returns an error\&. | ||
| .SH "AUTHOR" | ||
| .sp | ||
| Lisa Neigut <niftynei@gmail\&.com> is mainly responsible\&. | ||
| .SH "SEE ALSO" | ||
| .sp | ||
| lightning\-connect(7), lightning\-fundchannel(7), lightning\-fundchannel_start(7), lightning\-fundchannel_cancel(7) | ||
| .SH "RESOURCES" | ||
| .sp | ||
| Main web site: https://github\&.com/ElementsProject/lightning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| LIGHTNING-FUNDCHANNEL_COMPLETE(7) | ||
| ================================= | ||
| :doctype: manpage | ||
|
|
||
| NAME | ||
| ---- | ||
| lightning-fundchannel_complete - Command for completing channel establishment | ||
|
|
||
| SYNOPSIS | ||
| -------- | ||
| *fundchannel_complete* 'id' 'txid' 'txout' | ||
|
|
||
| DESCRIPTION | ||
| ----------- | ||
| `fundchannel_complete` is a lower level RPC command. It allows a user to complete an initiated | ||
| channel establishment with a connected peer | ||
|
|
||
| 'id' is the node id of the remote peer | ||
|
|
||
| 'txid' is the hex string of the funding transaction id. | ||
|
|
||
| 'txout' is the integer outpoint of the funding output for this channel. | ||
|
|
||
| Note that the funding transaction should not be broadcast until after channel | ||
| establishment has been successfully completed, as the commitment transactions | ||
| for this channel are not secured until this command succesfully completes. | ||
|
|
||
| RETURN VALUE | ||
| ------------ | ||
| On success, returns a confirmation that 'commitments_secured' and the | ||
| derived 'channel_id'. | ||
|
|
||
| On failure, returns an error. | ||
|
|
||
| AUTHOR | ||
| ------ | ||
| Lisa Neigut <niftynei@gmail.com> is mainly responsible. | ||
|
|
||
| SEE ALSO | ||
| -------- | ||
| lightning-connect(7), lightning-fundchannel(7), lightning-fundchannel_start(7), | ||
| lightning-fundchannel_cancel(7) | ||
|
|
||
| RESOURCES | ||
| --------- | ||
| Main web site: https://github.com/ElementsProject/lightning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| '\" t | ||
| .\" Title: lightning-fundchannel_start | ||
| .\" Author: [see the "AUTHOR" section] | ||
| .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> | ||
| .\" Date: 06/05/2019 | ||
| .\" Manual: \ \& | ||
| .\" Source: \ \& | ||
| .\" Language: English | ||
| .\" | ||
| .TH "LIGHTNING\-FUNDCHANN" "7" "06/05/2019" "\ \&" "\ \&" | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * Define some portability stuff | ||
| .\" ----------------------------------------------------------------- | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .\" http://bugs.debian.org/507673 | ||
| .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html | ||
| .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| .ie \n(.g .ds Aq \(aq | ||
| .el .ds Aq ' | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * set default formatting | ||
| .\" ----------------------------------------------------------------- | ||
| .\" disable hyphenation | ||
| .nh | ||
| .\" disable justification (adjust text to left margin only) | ||
| .ad l | ||
| .\" ----------------------------------------------------------------- | ||
| .\" * MAIN CONTENT STARTS HERE * | ||
| .\" ----------------------------------------------------------------- | ||
| .SH "NAME" | ||
| lightning-fundchannel_start \- Command for initiating channel establishment for a lightning channel | ||
| .SH "SYNOPSIS" | ||
| .sp | ||
| \fBfundchannel_start\fR \fIid\fR \fIsatoshi\fR [\fIfeerate\fR \fIannounce\fR] | ||
| .SH "DESCRIPTION" | ||
| .sp | ||
| fundchannel_start is a lower level RPC command\&. It allows a user to initiate channel establishment with a connected peer\&. | ||
| .sp | ||
| \fIid\fR is the node id of the remote peer\&. | ||
| .sp | ||
| \fIsatoshi\fR is the satoshi value that the channel will be funded at\&. This value MUST be accurate, otherwise the negotiated commitment transactions will not encompass the correct channel value\&. | ||
| .sp | ||
| \fIfeerate\fR is an optional field\&. Sets the feerate for subsequent commitment transactions\&. | ||
| .sp | ||
| \fIannounce\fR whether or not to annouce this channel\&. | ||
| .SH "RETURN VALUE" | ||
| .sp | ||
| On success, returns the \fIfunding_address\fR for the channel\&. | ||
| .sp | ||
| On failure, returns an error\&. | ||
| .SH "AUTHOR" | ||
| .sp | ||
| Lisa Neigut <niftynei@gmail\&.com> is mainly responsible\&. | ||
| .SH "SEE ALSO" | ||
| .sp | ||
| lightning\-connect(7), lightning\-fundchannel(7), lightning\-fundchannel_complete(7), lightning\-fundchannel_cancel(7) | ||
| .SH "RESOURCES" | ||
| .sp | ||
| Main web site: https://github\&.com/ElementsProject/lightning |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We already have these helpers in bitcoin/script.c: