From 3ccb6d6e7aa5eca8ddfb90714dd37ac39dc98ee8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 6 Apr 2021 06:42:11 +0930 Subject: [PATCH] Makefile: update to latest BOLT versions. The main change which affects us is that 2016 blocks to forget a channel is a fixed number in the spec; we make this clear by renaming the (developer-only) max_funding_unconfirmed to dev_max_funding_unconfirmed and making it compile DEVELOPER only. Signed-off-by: Rusty Russell --- Makefile | 2 +- channeld/test/run-commit_tx.c | 3 ++- channeld/test/run-full_channel.c | 3 ++- common/bolt11.c | 2 +- common/shutdown_scriptpubkey.h | 2 +- lightningd/channel_control.c | 5 ++--- lightningd/dual_open_control.c | 2 +- lightningd/lightningd.c | 2 +- lightningd/lightningd.h | 8 ++++---- lightningd/options.c | 2 +- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 192d4ec1e..935ef9516 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ CCANDIR := ccan # Where we keep the BOLT RFCs BOLTDIR := ../lightning-rfc/ -BOLTVERSION := edd45ecf22095ce97c1b5e9136a7d79351bd68cb +BOLTVERSION := b201efe0546120c14bf154ce5f4e18da7243fe7a -include config.vars diff --git a/channeld/test/run-commit_tx.c b/channeld/test/run-commit_tx.c index 47d18876d..a825b66f6 100644 --- a/channeld/test/run-commit_tx.c +++ b/channeld/test/run-commit_tx.c @@ -513,7 +513,8 @@ int main(int argc, const char *argv[]) * * To start, common basic parameters for each test vector are defined: * the HTLCs are not used for the first "simple commitment tx with no - * HTLCs" test. + * HTLCs" test, and HTLCs 5 and 6 are only used in the "same amount and + * preimage" test. * * funding_tx_id: 8984484a580b825b9972d7adb15050b3ab624ccd731946b3eeddb92f4e7ef6be * funding_output_index: 0 diff --git a/channeld/test/run-full_channel.c b/channeld/test/run-full_channel.c index 85f1c455b..acee63ef0 100644 --- a/channeld/test/run-full_channel.c +++ b/channeld/test/run-full_channel.c @@ -392,7 +392,8 @@ int main(int argc, const char *argv[]) * * To start, common basic parameters for each test vector are defined: * the HTLCs are not used for the first "simple commitment tx with no - * HTLCs" test. + * HTLCs" test, and HTLCs 5 and 6 are only used in the "same amount and + * preimage" test. * * funding_tx_id: 8984484a580b825b9972d7adb15050b3ab624ccd731946b3eeddb92f4e7ef6be * funding_output_index: 0 diff --git a/common/bolt11.c b/common/bolt11.c index 8b0a014e0..36a1feacd 100644 --- a/common/bolt11.c +++ b/common/bolt11.c @@ -594,7 +594,7 @@ struct bolt11 *bolt11_decode_nosig(const tal_t *ctx, const char *str, * * The human-readable part of a Lightning invoice consists of two sections: * 1. `prefix`: `ln` + BIP-0173 currency prefix (e.g. `lnbc` for Bitcoin mainnet, - * `lntb` for Bitcoin testnet, and `lnbcrt` for Bitcoin regtest) + * `lntb` for Bitcoin testnet, `lntbs` for Bitcoin signet, and `lnbcrt` for Bitcoin regtest) * 1. `amount`: optional number in that currency, followed by an optional * `multiplier` letter. The unit encoded here is the 'social' convention of a payment unit -- in the case of Bitcoin the unit is 'bitcoin' NOT satoshis. */ diff --git a/common/shutdown_scriptpubkey.h b/common/shutdown_scriptpubkey.h index 942a112ea..65544f42d 100644 --- a/common/shutdown_scriptpubkey.h +++ b/common/shutdown_scriptpubkey.h @@ -8,7 +8,7 @@ * 1. `OP_DUP` `OP_HASH160` `20` 20-bytes `OP_EQUALVERIFY` `OP_CHECKSIG` * (pay to pubkey hash), OR * 2. `OP_HASH160` `20` 20-bytes `OP_EQUAL` (pay to script hash), OR - * 3. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey), OR + * 3. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey hash), OR * 4. `OP_0` `32` 32-bytes (version 0 pay to witness script hash) * * A receiving node: diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 36754ca26..53aa43773 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -679,14 +679,13 @@ is_fundee_should_forget(struct lightningd *ld, struct channel *channel, u32 block_height) { - u32 max_funding_unconfirmed = ld->max_funding_unconfirmed; - /* BOLT #2: * * A non-funding node (fundee): * - SHOULD forget the channel if it does not see the - * correct funding transaction after a reasonable timeout. + * correct funding transaction after a timeout of 2016 blocks. */ + u32 max_funding_unconfirmed = IFDEV(ld->dev_max_funding_unconfirmed, 2016); /* Only applies if we are fundee. */ if (channel->opener == LOCAL) diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index a2d4d8e41..f367cc671 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -1229,7 +1229,7 @@ static void handle_peer_wants_to_close(struct subd *dualopend, * 1. `OP_DUP` `OP_HASH160` `20` 20-bytes `OP_EQUALVERIFY` `OP_CHECKSIG` * (pay to pubkey hash), OR * 2. `OP_HASH160` `20` 20-bytes `OP_EQUAL` (pay to script hash), OR - * 3. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey), OR + * 3. `OP_0` `20` 20-bytes (version 0 pay to witness pubkey hash), OR * 4. `OP_0` `32` 32-bytes (version 0 pay to witness script hash) * * A receiving node: diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 3aa98da41..ca3ae7a35 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -140,6 +140,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->dev_force_tmp_channel_id = NULL; ld->dev_no_htlc_timeout = false; ld->dev_no_version_checks = false; + ld->dev_max_funding_unconfirmed = 2016; #endif /*~ These are CCAN lists: an embedded double-linked list. It's not @@ -226,7 +227,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->use_proxy_always = false; ld->pure_tor_setup = false; ld->tor_service_password = NULL; - ld->max_funding_unconfirmed = 2016; /*~ This is initialized later, but the plugin loop examines this, * so set it to NULL explicitly now. */ diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index bef1bbc8f..4e159b12b 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -194,10 +194,6 @@ struct lightningd { /* PID file */ char *pidfile; - /* Number of blocks we wait for a channel to get funded - * if we are the fundee. */ - u32 max_funding_unconfirmed; - /* RPC which asked us to shutdown, if non-NULL */ struct io_conn *stop_conn; /* RPC response to send once we've shut down. */ @@ -243,6 +239,10 @@ struct lightningd { bool dev_no_htlc_timeout; bool dev_no_version_checks; + + /* Number of blocks we wait for a channel to get funded + * if we are the fundee. */ + u32 dev_max_funding_unconfirmed; #endif /* DEVELOPER */ /* tor support */ diff --git a/lightningd/options.c b/lightningd/options.c index 0160287ad..900129e22 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -581,7 +581,7 @@ static void dev_register_opts(struct lightningd *ld) "Force HSM to use these for all per-channel secrets"); opt_register_arg("--dev-max-funding-unconfirmed-blocks", opt_set_u32, opt_show_u32, - &ld->max_funding_unconfirmed, + &ld->dev_max_funding_unconfirmed, "Maximum number of blocks we wait for a channel " "funding transaction to confirm, if we are the " "fundee.");