Browse Source

dualfund: add feature flag for dual-funding

turn off until we're ready to test both sides
bump-pyln-proto
niftynei 4 years ago
committed by Rusty Russell
parent
commit
9c89184c1f
  1. 12
      common/features.c
  2. 5
      common/features.h
  3. 33
      lightningd/dual_open_control.c
  4. 12
      lightningd/peer_control.c
  5. 9
      lightningd/test/run-invoice-select-inchan.c
  6. 2
      wallet/db_postgres_sqlgen.c
  7. 2
      wallet/db_sqlite3_sqlgen.c
  8. 4
      wallet/statements_gettextgen.po
  9. 9
      wallet/test/run-wallet.c

12
common/features.c

@ -78,6 +78,12 @@ static const struct feature_style feature_styles[] = {
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_REPRESENT_AS_OPTIONAL} },
{ OPT_DUAL_FUND,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
#endif
};
@ -106,6 +112,12 @@ static const struct dependency feature_deps[] = {
*/
#if EXPERIMENTAL_FEATURES
{ OPT_ANCHOR_OUTPUTS, OPT_STATIC_REMOTEKEY },
/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9:
* Name | Description | Context | Dependencies |
* ...
* `option_dual_fund` | ... | ... | `option_anchor_outputs`
*/
{ OPT_DUAL_FUND, OPT_ANCHOR_OUTPUTS },
#endif
};

5
common/features.h

@ -115,5 +115,10 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES);
*/
#if EXPERIMENTAL_FEATURES
#define OPT_ONION_MESSAGES 102
/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9:
* | 222/223 | `option_dual_fund` | ... IN9 ...
*/
#define OPT_DUAL_FUND 222
#endif
#endif /* LIGHTNING_COMMON_FEATURES_H */

33
lightningd/dual_open_control.c

@ -658,32 +658,13 @@ wallet_commit_channel(struct lightningd *ld,
/* old_remote_per_commit not valid yet, copy valid one. */
channel_info->old_remote_per_commit = channel_info->remote_per_commit;
/* BOLT-a12da24dd0102c170365124782b46d9710950ac1 #2:
* 1. type: 35 (`funding_signed`)
* 2. data:
* * [`channel_id`:`channel_id`]
* * [`signature`:`signature`]
*
* #### Requirements
*
* Both peers:
* - if `option_static_remotekey` or `option_anchor_outputs` was negotiated:
* - `option_static_remotekey` or `option_anchor_outputs` applies to all commitment
* transactions
* - otherwise:
* - `option_static_remotekey` or `option_anchor_outputs` does not apply to any commitment
* transactions
*/
/* i.e. We set it now for the channel permanently. */
option_static_remotekey
= feature_negotiated(ld->our_features,
uc->peer->their_features,
OPT_STATIC_REMOTEKEY);
option_anchor_outputs
= feature_negotiated(ld->our_features,
uc->peer->their_features,
OPT_ANCHOR_OUTPUTS);
/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9
* | 222/223 | `option_dual_fund`
* | Use v2 of channel open, enables dual funding
* | IN9
* | `option_anchor_outputs` */
option_static_remotekey = true;
option_anchor_outputs = true;
channel = new_channel(uc->peer, uc->dbid,
NULL, /* No shachain yet */

12
lightningd/peer_control.c

@ -42,6 +42,7 @@
#include <lightningd/channel_control.h>
#include <lightningd/closing_control.h>
#include <lightningd/connect_control.h>
#include <lightningd/dual_open_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/json.h>
#include <lightningd/jsonrpc.h>
@ -1004,7 +1005,14 @@ peer_connected_hook_cb(struct peer_connected_hook_payload *payload STEALS,
error = NULL;
send_error:
peer_start_openingd(peer, payload->pps, error);
#if EXPERIMENTAL_FEATURES
if (feature_negotiated(ld->our_features,
peer->their_features,
OPT_DUAL_FUND)) {
peer_start_dualopend(peer, payload->pps, error);
} else
#endif /* EXPERIMENTAL_FEATURES */
peer_start_openingd(peer, payload->pps, error);
tal_free(payload);
}
@ -1258,6 +1266,7 @@ static struct command_result *json_listpeers(struct command *cmd,
return command_success(cmd, response);
}
/* Magic marker: remove at your own peril! */
static const struct json_command listpeers_command = {
"listpeers",
"network",
@ -1468,7 +1477,6 @@ static struct command_result *json_close(struct command *cmd,
return command_still_pending(cmd);
}
/* Magic marker: remove at your own peril! */
static const struct json_command close_command = {
"close",
"channels",

9
lightningd/test/run-invoice-select-inchan.c

@ -138,6 +138,10 @@ void fatal(const char *fmt UNNEEDED, ...)
/* Generated stub for feature_is_set */
bool feature_is_set(const u8 *features UNNEEDED, size_t bit UNNEEDED)
{ fprintf(stderr, "feature_is_set called!\n"); abort(); }
/* Generated stub for feature_negotiated */
bool feature_negotiated(const struct feature_set *our_features UNNEEDED,
const u8 *their_features UNNEEDED, size_t f UNNEEDED)
{ fprintf(stderr, "feature_negotiated called!\n"); abort(); }
/* Generated stub for fixup_htlcs_out */
void fixup_htlcs_out(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "fixup_htlcs_out called!\n"); abort(); }
@ -471,6 +475,11 @@ void peer_start_closingd(struct channel *channel UNNEEDED,
bool reconnected UNNEEDED,
const u8 *channel_reestablish UNNEEDED)
{ fprintf(stderr, "peer_start_closingd called!\n"); abort(); }
/* Generated stub for peer_start_dualopend */
void peer_start_dualopend(struct peer *peer UNNEEDED,
struct per_peer_state *pps UNNEEDED,
const u8 *send_msg UNNEEDED)
{ fprintf(stderr, "peer_start_dualopend called!\n"); abort(); }
/* Generated stub for peer_start_openingd */
void peer_start_openingd(struct peer *peer UNNEEDED,
struct per_peer_state *pps UNNEEDED,

2
wallet/db_postgres_sqlgen.c

@ -1648,4 +1648,4 @@ struct db_query db_postgres_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:0838dffa4a6f4f42152ad48122d435039c2cff5fa8c067e2bd2b54ef8cb92ee9
// SHA256STAMP:750952e0c2a627617fea597d3faa6b41b736c6a67101343b37ec86c47da7bad7

2
wallet/db_sqlite3_sqlgen.c

@ -1648,4 +1648,4 @@ struct db_query db_sqlite3_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:0838dffa4a6f4f42152ad48122d435039c2cff5fa8c067e2bd2b54ef8cb92ee9
// SHA256STAMP:750952e0c2a627617fea597d3faa6b41b736c6a67101343b37ec86c47da7bad7

4
wallet/statements_gettextgen.po

@ -1082,7 +1082,7 @@ msgstr ""
msgid "not a valid SQL statement"
msgstr ""
#: wallet/test/run-wallet.c:1346
#: wallet/test/run-wallet.c:1355
msgid "INSERT INTO channels (id) VALUES (1);"
msgstr ""
# SHA256STAMP:b38439695ca8ff636fbd7b7b17d156d5d5d5408b8d5dd228d20744b7e25da2be
# SHA256STAMP:a2c4fd6e26d81d871d9ee5201a844e09d94b4ea50c3690060dea4dd640ef007b

9
wallet/test/run-wallet.c

@ -111,6 +111,10 @@ char *encode_scriptpubkey_to_addr(const tal_t *ctx UNNEEDED,
/* Generated stub for fatal */
void fatal(const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "fatal called!\n"); abort(); }
/* Generated stub for feature_negotiated */
bool feature_negotiated(const struct feature_set *our_features UNNEEDED,
const u8 *their_features UNNEEDED, size_t f UNNEEDED)
{ fprintf(stderr, "feature_negotiated called!\n"); abort(); }
/* Generated stub for fromwire_channeld_dev_memleak_reply */
bool fromwire_channeld_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ fprintf(stderr, "fromwire_channeld_dev_memleak_reply called!\n"); abort(); }
@ -578,6 +582,11 @@ void peer_start_closingd(struct channel *channel UNNEEDED,
bool reconnected UNNEEDED,
const u8 *channel_reestablish UNNEEDED)
{ fprintf(stderr, "peer_start_closingd called!\n"); abort(); }
/* Generated stub for peer_start_dualopend */
void peer_start_dualopend(struct peer *peer UNNEEDED,
struct per_peer_state *pps UNNEEDED,
const u8 *send_msg UNNEEDED)
{ fprintf(stderr, "peer_start_dualopend called!\n"); abort(); }
/* Generated stub for peer_start_openingd */
void peer_start_openingd(struct peer *peer UNNEEDED,
struct per_peer_state *pps UNNEEDED,

Loading…
Cancel
Save