From a5b3818204fcee7f52170837dc1f79a0aeb351d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorkil=20V=C3=A6rge?= Date: Thu, 14 Nov 2019 08:38:53 +0100 Subject: [PATCH 001/103] Specify that resolution of amount is msat When the `p` multiplier is used, the amount MUST be divisible by 10 since the resolution used internally is millisatoshi. This addresses but does not close #692. --- 11-payment-encoding.md | 1 + 1 file changed, 1 insertion(+) diff --git a/11-payment-encoding.md b/11-payment-encoding.md index b03409311..66da25a28 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -64,6 +64,7 @@ A writer: - if a specific minimum `amount` is required for successful payment: - MUST include that `amount`. - MUST encode `amount` as a positive decimal integer with no leading 0s. + - MUST request `amount` divisible by ten if the `p` multiplier is used. - SHOULD use the shortest representation possible, by using the largest multiplier or omitting the multiplier. From efd16b9b20b75066f86d78d6f1853f48faefa072 Mon Sep 17 00:00:00 2001 From: ueno Date: Thu, 14 Nov 2019 19:10:09 +0900 Subject: [PATCH 002/103] fix tag --- 01-messaging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-messaging.md b/01-messaging.md index 90cbaa45b..a89ba53e9 100644 --- a/01-messaging.md +++ b/01-messaging.md @@ -875,7 +875,7 @@ failure: ## References -1. http://www.unicode.org/charts/PDF/U2600.pdf +1. http://www.unicode.org/charts/PDF/U2600.pdf ## Authors From 3a0a7fd06489d822d6cfd6027b4ed233fceb4973 Mon Sep 17 00:00:00 2001 From: ueno Date: Tue, 12 Nov 2019 11:33:40 +0900 Subject: [PATCH 003/103] remove `funding_locked` future section --- 02-peer-protocol.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/02-peer-protocol.md b/02-peer-protocol.md index 4c94c5408..9db5557b1 100644 --- a/02-peer-protocol.md +++ b/02-peer-protocol.md @@ -425,11 +425,6 @@ funds are at risk. If the fundee were to remember the channel forever, this would create a Denial of Service risk; therefore, forgetting it is recommended (even if the promise of `push_msat` is significant). -#### Future - -An SPV proof could be added and block hashes could be routed in separate -messages. - ## Channel Close Nodes can negotiate a mutual close of the connection, which unlike a From b84d09e0761ce3a1b6b14f7bc28091a72049d12d Mon Sep 17 00:00:00 2001 From: darosior Date: Tue, 1 Oct 2019 21:00:28 +0200 Subject: [PATCH 004/103] bolt07: remove trailing tabs Tabs or spaces ? Spaces seems to largely beat tabs in this files (and more globally in the repo). --- 07-routing-gossip.md | 53 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/07-routing-gossip.md b/07-routing-gossip.md index e1d43c76a..3d16db96d 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -458,15 +458,15 @@ The origin node: - otherwise: - MUST set the `direction` bit of `channel_flags` to 1. - if the `htlc_maximum_msat` field is present: - - MUST set the `option_channel_htlc_max` bit of `message_flags` to 1. - - MUST set `htlc_maximum_msat` to the maximum value it will send through this channel for a single HTLC. - - MUST set this to less than or equal to the channel capacity. - - MUST set this to less than or equal to `max_htlc_value_in_flight_msat` - it received from the peer. - - for channels with `chain_hash` identifying the Bitcoin blockchain: - - MUST set this to less than 2^32. + - MUST set the `option_channel_htlc_max` bit of `message_flags` to 1. + - MUST set `htlc_maximum_msat` to the maximum value it will send through this channel for a single HTLC. + - MUST set this to less than or equal to the channel capacity. + - MUST set this to less than or equal to `max_htlc_value_in_flight_msat` + it received from the peer. + - for channels with `chain_hash` identifying the Bitcoin blockchain: + - MUST set this to less than 2^32. - otherwise: - - MUST set the `option_channel_htlc_max` bit of `message_flags` to 0. + - MUST set the `option_channel_htlc_max` bit of `message_flags` to 0. - MUST set bits in `channel_flags` and `message_flags `that are not assigned a meaning to 0. - MAY create and send a `channel_update` with the `disable` bit set to 1, to signal a channel's temporary unavailability (e.g. due to a loss of @@ -522,10 +522,10 @@ The receiving node: - MUST consider `htlc_maximum_msat` not to be present. - otherwise: - if `htlc_maximum_msat` is not present or greater than channel capacity: - - MAY blacklist this `node_id` - - SHOULD ignore this channel during route considerations. - - otherwise: - - SHOULD consider the `htlc_maximum_msat` when routing. + - MAY blacklist this `node_id` + - SHOULD ignore this channel during route considerations. + - otherwise: + - SHOULD consider the `htlc_maximum_msat` when routing. ### Rationale @@ -676,13 +676,13 @@ The receiver: - MUST reply with the latest `node_announcement` for `node_id_1` - if bit 4 of `query_flag` is set and it has received a `node_announcement` from `node_id_2`: - MUST reply with the latest `node_announcement` for `node_id_2` - - SHOULD NOT wait for the next outgoing gossip flush to send these. + - SHOULD NOT wait for the next outgoing gossip flush to send these. - SHOULD avoid sending duplicate `node_announcements` in response to a single `query_short_channel_ids`. - MUST follow these responses with `reply_short_channel_ids_end`. - if does not maintain up-to-date channel information for `chain_hash`: - - MUST set `complete` to 0. + - MUST set `complete` to 0. - otherwise: - - SHOULD set `complete` to 1. + - SHOULD set `complete` to 1. #### Rationale @@ -733,7 +733,7 @@ Though it is possible, it would not be very useful to ask for checksums without 2. types: 1. type: 1 (`timestamps_tlv`) 2. data: - * [`u8`:`encoding_type`] + * [`u8`:`encoding_type`] * [`...*byte`:`encoded_timestamps`] 1. type: 3 (`checksums_tlv`) 2. data: @@ -779,8 +779,7 @@ The receiver of `query_channel_range`: - if it has not sent all `reply_channel_range` to a previously received `query_channel_range` from this sender: - MAY fail the connection. - MUST respond with one or more `reply_channel_range` whose combined range - cover the requested `first_blocknum` to `first_blocknum` plus - `number_of_blocks` minus one. + cover the requested `first_blocknum` to `first_blocknum` plus `number_of_blocks` minus one. - For each `reply_channel_range`: - MUST set with `chain_hash` equal to that of `query_channel_range`, - MUST encode a `short_channel_id` for every open channel it knows in blocks `first_blocknum` to `first_blocknum` plus `number_of_blocks` minus one. @@ -830,17 +829,17 @@ The receiver: - SHOULD send all gossip messages whose `timestamp` is greater or equal to `first_timestamp`, and less than `first_timestamp` plus `timestamp_range`. - - MAY wait for the next outgoing gossip flush to send these. + - MAY wait for the next outgoing gossip flush to send these. - SHOULD restrict future gossip messages to those whose `timestamp` is greater or equal to `first_timestamp`, and less than `first_timestamp` plus `timestamp_range`. - If a `channel_announcement` has no corresponding `channel_update`s: - - MUST NOT send the `channel_announcement`. + - MUST NOT send the `channel_announcement`. - Otherwise: - - MUST consider the `timestamp` of the `channel_announcement` to be the `timestamp` of a corresponding `channel_update`. - - MUST consider whether to send the `channel_announcement` after receiving the first corresponding `channel_update`. + - MUST consider the `timestamp` of the `channel_announcement` to be the `timestamp` of a corresponding `channel_update`. + - MUST consider whether to send the `channel_announcement` after receiving the first corresponding `channel_update`. - If a `channel_announcement` is sent: - - MUST send the `channel_announcement` prior to any corresponding `channel_update`s and `node_announcement`s. + - MUST send the `channel_announcement` prior to any corresponding `channel_update`s and `node_announcement`s. #### Rationale @@ -875,7 +874,7 @@ interactions with them. A node: - if the `gossip_queries` feature is negotiated: - - MUST NOT relay any gossip messages unless explicitly requested. + - MUST NOT relay any gossip messages unless explicitly requested. - otherwise: - if it requires a full copy of the peer's routing state: - SHOULD set the `initial_routing_sync` flag to 1. @@ -907,7 +906,7 @@ A receiving node: A node: - if the `gossip_queries` feature is negotiated: - - MUST not send gossip until it receives `gossip_timestamp_filter`. + - MUST not send gossip until it receives `gossip_timestamp_filter`. - SHOULD flush outgoing gossip messages once every 60 seconds, independently of the arrival times of the messages. - Note: this results in staggered announcements that are unique (not @@ -1072,7 +1071,7 @@ per [HTLC Fees](#htlc-fees): fee_base_msat + ( amount_to_forward * fee_proportional_millionths / 1000000 ) - 200 + ( 4999999 * 2000 / 1000000 ) = 10199 + 200 + ( 4999999 * 2000 / 1000000 ) = 10199 Similarly, it would need to add B->C's `channel_update` `cltv_expiry` (20), C's requested `min_final_cltv_expiry` (9), and the cost for the _shadow route_ (42). @@ -1092,7 +1091,7 @@ A->D's `update_add_htlc` message would be: * `amount_msat`: 5020398 * `cltv_expiry`: current-block-height + 40 + 9 + 42 * `onion_routing_packet`: - * `amt_to_forward` = 4999999 + * `amt_to_forward` = 4999999 * `outgoing_cltv_value` = current-block-height + 9 + 42 And D->C's `update_add_htlc` would again be the same as B->C's direct payment From 5f57ee36895c6aea3ec9433ead9ecb444de30559 Mon Sep 17 00:00:00 2001 From: Janus Troelsen Date: Thu, 21 Nov 2019 22:05:23 -0600 Subject: [PATCH 005/103] BOLT-02: Fix link to channel_id section (#704) --- 02-peer-protocol.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02-peer-protocol.md b/02-peer-protocol.md index 9db5557b1..33d772022 100644 --- a/02-peer-protocol.md +++ b/02-peer-protocol.md @@ -6,7 +6,7 @@ operation, and closing. # Table of Contents * [Channel](#channel) - * [Definition of `channel_id`](#definition-of-channel-id) + * [Definition of `channel_id`](#definition-of-channel_id) * [Channel Establishment](#channel-establishment) * [The `open_channel` Message](#the-open_channel-message) * [The `accept_channel` Message](#the-accept_channel-message) From 206084c9399abcfacdc95800acc27ebc5ca40b0c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 17 Sep 2019 14:51:17 +0930 Subject: [PATCH 006/103] BOLT 9: flatten feature fields. We simply specify, in each case, where they will appear ("Context"). Because `globalfeatures` is already in use, we fold that into the renamed `localfeatures` field to unify them (now called `features`), but dissuade further use. Note also: we REQUIRE minimal `features` field in channel_announcement, since otherwise both sides of channel will not agree and not be able to create their signatures! Consider these theoretical future features: `opt_dlog_chan`: a new channel type which uses a new discrete log HTLC type, but can't support traditional HTLC: * `init`: presents as odd (optional) or even (if traditional channels not supported) * `node_announcement`: the same as above, so you can seek suitable peers. * `channel_announcement`: presents as even (compulsory), since users need to use the new HTLCs. `opt_wumbochan`: a node which allows channels > 2^24 satoshis: * `init`: presents as odd (optional), or maybe even (if you only want giant channels) * `node_announcement`: the same as above, so you can seek suitable peers. * `channel_announcement`: not present, since size of channel indicates capacity. `opt_wumbohtlc`: a channel which allows HTLCs > 2^32 millisatoshis: * `init`: presents as odd (optional), or even (compulsory) * `node_announcement`: the same as above, so you can seek suitable peers. * `channel_announcement`: odd (optional) since you can use the channel without understanding what this option means. Signed-off-by: Rusty Russell Co-Authored-By: Bastien Teinturier <31281497+t-bast@users.noreply.github.com> --- .aspell.en.pws | 1 + 01-messaging.md | 20 +++++++------- 02-peer-protocol.md | 8 ------ 07-routing-gossip.md | 4 ++- 09-features.md | 62 +++++++++++++++++++++++++------------------- 5 files changed, 49 insertions(+), 46 deletions(-) diff --git a/.aspell.en.pws b/.aspell.en.pws index 97b6ebdbd..bf7e2213a 100644 --- a/.aspell.en.pws +++ b/.aspell.en.pws @@ -371,3 +371,4 @@ tlvs snprintf GitHub IRC +bitmasks diff --git a/01-messaging.md b/01-messaging.md index a89ba53e9..7fd3e2707 100644 --- a/01-messaging.md +++ b/01-messaging.md @@ -226,18 +226,17 @@ The following convenience types are also defined: Once authentication is complete, the first message reveals the features supported or required by this node, even if this is a reconnection. -[BOLT #9](09-features.md) specifies lists of global and local features. Each feature is generally represented in `globalfeatures` or `localfeatures` by 2 bits. The least-significant bit is numbered 0, which is _even_, and the next most significant bit is numbered 1, which is _odd_. +[BOLT #9](09-features.md) specifies lists of features. Each feature is generally represented by 2 bits. The least-significant bit is numbered 0, which is _even_, and the next most significant bit is numbered 1, which is _odd_. For historical reasons, features are divided into global and local feature bitmasks. -Both fields `globalfeatures` and `localfeatures` MUST be padded to bytes with 0s. +The `features` field MUST be padded to bytes with 0s. 1. type: 16 (`init`) 2. data: * [`u16`:`gflen`] * [`gflen*byte`:`globalfeatures`] - * [`u16`:`lflen`] - * [`lflen*byte`:`localfeatures`] + * [`u16`:`flen`] + * [`flen*byte`:`features`] -The 2-byte `gflen` and `lflen` fields indicate the number of bytes in the immediately following field. #### Requirements @@ -245,10 +244,12 @@ The sending node: - MUST send `init` as the first Lightning message for any connection. - MUST set feature bits as defined in [BOLT #9](09-features.md). - MUST set any undefined feature bits to 0. - - SHOULD use the minimum lengths required to represent the feature fields. + - SHOULD NOT set features greater than 13 in `globalfeatures`. + - SHOULD use the minimum length required to represent the `features` field. The receiving node: - MUST wait to receive `init` before sending any other messages. + - MUST combine (logical OR) the two feature bitmaps into one logical `features` map. - MUST respond to known feature bits as specified in [BOLT #9](09-features.md). - upon receiving unknown _odd_ feature bits that are non-zero: - MUST ignore the bit. @@ -257,15 +258,14 @@ The receiving node: #### Rationale +There used to be two feature bitfields here, but for backwards compatibility they're now +combined into one. + This semantic allows both future incompatible changes and future backward compatible changes. Bits should generally be assigned in pairs, in order that optional features may later become compulsory. Nodes wait for receipt of the other's features to simplify error diagnosis when features are incompatible. -The feature masks are split into local features (which only affect the -protocol between these two nodes) and global features (which can affect -HTLCs and are thus also advertised to other nodes). - ### The `error` Message For simplicity of diagnosis, it's often useful to tell a peer that something is incorrect. diff --git a/02-peer-protocol.md b/02-peer-protocol.md index 33d772022..1f4f0a5ee 100644 --- a/02-peer-protocol.md +++ b/02-peer-protocol.md @@ -187,8 +187,6 @@ The `shutdown_scriptpubkey` allows the sending node to commit to where funds will go on mutual close, which the remote node should enforce even if a node is compromised later. -[ FIXME: Describe dangerous feature bit for larger channel amounts. ] - #### Requirements The sending node: @@ -264,12 +262,6 @@ are above both `dust_limit_satoshis`. Details for how to handle a channel failure can be found in [BOLT 5:Failing a Channel](05-onchain.md#failing-a-channel). -#### Future - -It would be easy to have a local feature bit which indicated that a -receiving node was prepared to fund a channel, which would reverse this -protocol. - ### The `accept_channel` Message This message contains information about a node and indicates its diff --git a/07-routing-gossip.md b/07-routing-gossip.md index 3d16db96d..822b02be1 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -180,7 +180,8 @@ The origin node: - MUST set `bitcoin_signature_1` and `bitcoin_signature_2` to valid signatures of the hash `h` (using `bitcoin_key_1` and `bitcoin_key_2`'s respective secrets). - - SHOULD set `len` to the minimum length required to hold the `features` bits + - MUST set `features` based on what features were negotiated for this channel, according to [BOLT #9](09-features.md#assigned-features-flags) + - MUST set `len` to the minimum length required to hold the `features` bits it sets. The receiving node: @@ -311,6 +312,7 @@ The origin node: to 0. - SHOULD ensure `ipv4_addr` AND `ipv6_addr` are routable addresses. - MUST NOT include more than one `address descriptor` of the same type. + - MUST set `features` according to [BOLT #9](09-features.md#assigned-features-flags) - SHOULD set `flen` to the minimum length required to hold the `features` bits it sets. diff --git a/09-features.md b/09-features.md index ee79290d4..4677b1111 100644 --- a/09-features.md +++ b/09-features.md @@ -1,14 +1,10 @@ # BOLT #9: Assigned Feature Flags -This document tracks the assignment of `localfeatures` and `globalfeatures` -flags in the `init` message ([BOLT #1](01-messaging.md)) along with the -`features` flag fields in the `channel_announcement` and `node_announcement` -messages ([BOLT #7](07-routing-gossip.md)). -The flags are tracked separately, since new flags will likely be added over time. - -The `features` flags in the routing messages are a subset of the -`globalfeatures` flags, as `localfeatures`, by definition, are only of interest -to direct peers. +This document tracks the assignment of `features` flags in the `init` +message ([BOLT #1](01-messaging.md)), as well as `features` fields in +the `channel_announcement` and `node_announcement` messages ([BOLT +#7](07-routing-gossip.md)). The flags are tracked separately, since +new flags will likely be added over time. Flags are numbered from the least-significant bit, at bit 0 (i.e. 0x1, an _even_ bit). They are generally assigned in pairs so that features @@ -16,29 +12,41 @@ can be introduced as optional (_odd_ bits) and later upgraded to be compulsory (_even_ bits), which will be refused by outdated nodes: see [BOLT #1: The `init` Message](01-messaging.md#the-init-message). -## Assigned `localfeatures` flags - -These flags may only be used in the `init` message: - -| Bits | Name | Description | Link | -|-------|----------------------------------|---------------------------------------------------------------------------|------------------------------| -| 0/1 | `option_data_loss_protect` | Requires or supports extra `channel_reestablish` fields | [BOLT #2][bolt02-retransmit] | -| 3 | `initial_routing_sync` | Indicates that the sending node needs a complete routing information dump | [BOLT #7][bolt07-sync] | -| 4/5 | `option_upfront_shutdown_script` | Commits to a shutdown scriptpubkey when opening channel | [BOLT #2][bolt02-open] | -| 6/7 | `gossip_queries` | More sophisticated gossip control | [BOLT #7][bolt07-query] | -| 10/11 | `gossip_queries_ex` | Gossip queries can include additional information | [BOLT #7][bolt07-query] | -| 12/13| `option_static_remotekey` | Static key for remote output | [BOLT #3](03-transactions.md) | +Some features don't make sense on a per-channels or per-node basis, so +each feature defines how it is presented in those contexts. Some +features may be required for opening a channel, but not a requirement +for use of the channel, so the presentation of those features depends +on the feature itself. -## Assigned `globalfeatures` flags +The Context column decodes as follows: +* `I`: presented in the `init` message. +* `N`: presented in the `node_announcement` messages +* `C`: presented in the `channel_announcement` message. +* `C-`: presented in the `channel_announcement` message, but always odd (optional). +* `C+`: presented in the `channel_announcement` message, but always even (required). -The following `globalfeatures` bits are currently assigned by this specification: - -| Bits | Name | Description | Link | -|------|-------------------|--------------------------------------------------------------------|---------------------------------------| -| 8/9 | `var_onion_optin` | This node requires/supports variable-length routing onion payloads | [Routing Onion Specification][bolt04] | +| Bits | Name | Description | Context | Link | +|-------|----------------------------------|-----------------------------------------------------------|----------|---------------------------------------| +| 0/1 | `option_data_loss_protect` | Requires or supports extra `channel_reestablish` fields | IN | [BOLT #2][bolt02-retransmit] | +| 3 | `initial_routing_sync` | Sending node needs a complete routing information dump | I | [BOLT #7][bolt07-sync] | +| 4/5 | `option_upfront_shutdown_script` | Commits to a shutdown scriptpubkey when opening channel | IN | [BOLT #2][bolt02-open] | +| 6/7 | `gossip_queries` | More sophisticated gossip control | IN | [BOLT #7][bolt07-query] | +| 8/9 | `var_onion_optin` | Requires/supports variable-length routing onion payloads | IN | [Routing Onion Specification][bolt04] | +| 10/11 | `gossip_queries_ex` | Gossip queries can include additional information | IN | [BOLT #7][bolt07-query] | +| 12/13| `option_static_remotekey` | Static key for remote output | IN | [BOLT #3](03-transactions.md) | ## Requirements +The origin node: + * If it supports a feature above, SHOULD set the corresponding odd + bit in all feature fields indicated by the Context column unless + indicated that it must set the even feature bit instead. + * If it requires a feature above, MUST set the corresponding even + feature bit in all feature fields indicated by the Context column, + unless indicated that it must set the odd feature bit instead. + * MUST NOT set feature bits it does not support. + * MUST NOT set feature bits in fields not specified by the table above. + The requirements for receiving specific bits are defined in the linked sections in the table above. The requirements for feature bits that are not defined above can be found in [BOLT #1: The `init` Message](01-messaging.md#the-init-message). From 6502e30e8f1052371dc3c6791328d218f4c1cde3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 17 Sep 2019 14:55:10 +0930 Subject: [PATCH 007/103] BOLT 7: always propagate announcements with unknown features. The feature fields refer to the properties of the channel/node, not the message itself, so we can still propagate them (and should, to avoid splitting the network). If we want to make an incompatible announcement message, we'll use a different type, or insert an even TLV type. Signed-off-by: Rusty Russell --- 07-routing-gossip.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/07-routing-gossip.md b/07-routing-gossip.md index 822b02be1..f4b2e2d3c 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -188,9 +188,7 @@ The receiving node: - MUST verify the integrity AND authenticity of the message by verifying the signatures. - if there is an unknown even bit in the `features` field: - - MUST NOT parse the remainder of the message. - - MUST NOT add the channel to its local network view. - - SHOULD NOT forward the announcement. + - MUST NOT attempt to route messages through the channel. - if the `short_channel_id`'s output does NOT correspond to a P2WSH (using `bitcoin_key_1` and `bitcoin_key_2`, as specified in [BOLT #3](03-transactions.md#funding-transaction-output)) OR the output is @@ -244,8 +242,6 @@ New channel features are possible in the future: backwards compatible (or optional) features will have _odd_ feature bits, while incompatible features will have _even_ feature bits (["It's OK to be odd!"](00-introduction.md#glossary-and-terminology-guide)). -Incompatible features will result in the announcement not being forwarded by -nodes that do not understand them. ## The `node_announcement` Message @@ -326,11 +322,7 @@ any future fields appended to the end): - SHOULD fail the connection. - MUST NOT process the message further. - if `features` field contains _unknown even bits_: - - MUST NOT parse the remainder of the message. - - MAY discard the message altogether. - SHOULD NOT connect to the node. - - MAY forward `node_announcement`s that contain an _unknown_ `features` _bit_, - regardless of if it has parsed the announcement or not. - SHOULD ignore the first `address descriptor` that does NOT match the types defined above. - if `addrlen` is insufficient to hold the address descriptors of the @@ -354,8 +346,9 @@ any future fields appended to the end): New node features are possible in the future: backwards compatible (or optional) ones will have _odd_ `feature` _bits_, incompatible ones will have -_even_ `feature` _bits_. These may be propagated by nodes even if they -cannot process the announcements themselves. +_even_ `feature` _bits_. These will be propagated normally; incompatible +feature bits here refer to the nodes, not the `node_announcement` message +itself. New address types may be added in the future; as address descriptors have to be ordered in ascending order, unknown ones can be safely ignored. From 8e69306e0a93375a1bbb1a0099f7ce3025ae4c0f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 30 Oct 2019 16:32:10 +1030 Subject: [PATCH 008/103] BOLT 11: use the same features for BOLT11 invoices as for others. A bit less dense, but avoids a separate feature space. Signed-off-by: Rusty Russell --- 09-features.md | 1 + 11-payment-encoding.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/09-features.md b/09-features.md index 4677b1111..8d3d025ea 100644 --- a/09-features.md +++ b/09-features.md @@ -24,6 +24,7 @@ The Context column decodes as follows: * `C`: presented in the `channel_announcement` message. * `C-`: presented in the `channel_announcement` message, but always odd (optional). * `C+`: presented in the `channel_announcement` message, but always even (required). +* `9`: presented in [BOLT 11](11-payment-encoding.md) invoices. | Bits | Name | Description | Context | Link | |-------|----------------------------------|-----------------------------------------------------------|----------|---------------------------------------| diff --git a/11-payment-encoding.md b/11-payment-encoding.md index b03409311..e9a28770a 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -272,7 +272,8 @@ Don't be like the school of [Little Bobby Tables](https://xkcd.com/327/). ## Feature Bits Feature bits allow forward and backward compatibility, and follow the -_it's ok to be odd_ rule. +_it's ok to be odd_ rule. Features appropriate for use in the `9` field +are marked in [BOLT 9](09-features.md). The field is big-endian. The least-significant bit is numbered 0, which is _even_, and the next most significant bit is numbered 1, From 0fb66ca6ccd935d60a48c80544d4b80d5583422c Mon Sep 17 00:00:00 2001 From: Arvanitis Christos Date: Mon, 9 Dec 2019 20:59:47 +0200 Subject: [PATCH 009/103] Minor href fix in Contents of 07-routing-gossip.md (#707) --- 07-routing-gossip.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/07-routing-gossip.md b/07-routing-gossip.md index f4b2e2d3c..ab4ece066 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -20,7 +20,7 @@ multiple `node_announcement` messages, in order to update the node information. # Table of Contents - * [Definition of `short_channel_id`](#definition-of-short-channel-id) + * [Definition of `short_channel_id`](#definition-of-short_channel_id) * [The `announcement_signatures` Message](#the-announcement_signatures-message) * [The `channel_announcement` Message](#the-channel_announcement-message) * [The `node_announcement` Message](#the-node_announcement-message) From 24226302741ec2701571c2036319fdb5554cb07c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 3 Dec 2019 14:19:40 +1030 Subject: [PATCH 010/103] BOLT 4: don't allow a "fee" for the final node. I recently made a cut & paste bug with the protocol tests, and paid an HTLC of amount 100M msat, but with only a 1M msat `amt_to_forward` in the hop_data. To my surprise, it was accepted. This is because we allow overpaying the routing fee (considered 0 for the final hop). This doesn't make sense for the final hop: anything but exact equality implies a bug, or that the previous node took the wrong amount from the payment. Signed-off-by: Rusty Russell --- 04-onion-routing.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index 17851c7a8..5944dc4ea 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -198,7 +198,7 @@ Field descriptions: * `amt_to_forward`: The amount, in millisatoshis, to forward to the next receiving peer specified within the routing information. - This value amount MUST include the origin node's computed _fee_ for the + For non-final nodes, this value amount MUST include the origin node's computed _fee_ for the receiving peer. When processing an incoming Sphinx packet and the HTLC message that it is encapsulated within, if the following inequality doesn't hold, then the HTLC should be rejected as it would indicate that a prior hop has @@ -206,9 +206,11 @@ Field descriptions: incoming_htlc_amt - fee >= amt_to_forward - Where `fee` is either calculated according to the receiving peer's advertised fee - schema (as described in [BOLT #7](07-routing-gossip.md#htlc-fees)) - or is 0, if the processing node is the final node. + Where `fee` is calculated according to the receiving peer's advertised fee + schema (as described in [BOLT #7](07-routing-gossip.md#htlc-fees). + + For the final node, this value MUST be exactly equal to the incoming htlc + amount, otherwise the HTLC should be rejected. * `outgoing_cltv_value`: The CLTV value that the _outgoing_ HTLC carrying the packet should have. From b2a3c2fb07fbdc3518210c399e6db4a7b5f61477 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 26 Nov 2019 13:43:48 +1030 Subject: [PATCH 011/103] BOLT 9: Add feature bits for payment_secret and basic_mpp. Signed-off-by: Rusty Russell --- .aspell.en.pws | 2 ++ 09-features.md | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.aspell.en.pws b/.aspell.en.pws index bf7e2213a..5ff04bfea 100644 --- a/.aspell.en.pws +++ b/.aspell.en.pws @@ -367,6 +367,8 @@ fips rfc varint CompactSize +multipath +mpp tlvs snprintf GitHub diff --git a/09-features.md b/09-features.md index 8d3d025ea..b05d83557 100644 --- a/09-features.md +++ b/09-features.md @@ -35,6 +35,8 @@ The Context column decodes as follows: | 8/9 | `var_onion_optin` | Requires/supports variable-length routing onion payloads | IN | [Routing Onion Specification][bolt04] | | 10/11 | `gossip_queries_ex` | Gossip queries can include additional information | IN | [BOLT #7][bolt07-query] | | 12/13| `option_static_remotekey` | Static key for remote output | IN | [BOLT #3](03-transactions.md) | +| 14/15 | `payment_secret` | Node supports `payment_secret` field | IN9 | [Routing Onion Specification][bolt04] | +| 16/17 | `basic_mpp` | Node can receive basic multi-part payments | IN9 | [BOLT #3][bolt04-mpp] | ## Requirements @@ -67,3 +69,4 @@ This work is licensed under a [Creative Commons Attribution 4.0 International Li [bolt04]: 04-onion-routing.md [bolt07-sync]: 07-routing-gossip.md#initial-sync [bolt07-query]: 07-routing-gossip.md#query-messages +[bolt04-mpp]: 04-onion-routing.md#basic-multi-part-payments From 5776d2a7ec69a1a87ffe499649753b0a12aa97c7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 26 Nov 2019 13:45:48 +1030 Subject: [PATCH 012/103] BOLT 11: Add payment_secret field (compulsory for new invoices). We also define what the basic_mpp feature means in an invoice, by reference to the next commit. Signed-off-by: Rusty Russell --- 11-payment-encoding.md | 67 ++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/11-payment-encoding.md b/11-payment-encoding.md index e9a28770a..9404c1c7b 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -129,6 +129,7 @@ Each Tagged Field is of the form: Currently defined tagged fields are: * `p` (1): `data_length` 52. 256-bit SHA256 payment_hash. Preimage of this provides proof of payment. +* `s` (16): `data_length` 52. This 256-bit secret prevents forwarding nodes from probing the payment recipient. * `d` (13): `data_length` variable. Short description of purpose of payment (UTF-8), e.g. '1 cup of coffee' or 'ナンセンス 1杯' * `n` (19): `data_length` 53. 33-byte public key of the payee node * `h` (23): `data_length` 52. 256-bit description of purpose of payment (SHA256). This is used to commit to an associated description that is over 639 bytes, but the transport mechanism for the description in that case is transport specific and not defined here. @@ -148,7 +149,7 @@ Currently defined tagged fields are: ### Requirements A writer: - - MUST include exactly one `p` field. + - MUST include exactly one `p` and `s` fields. - MUST set `payment_hash` to the SHA2 256-bit hash of the `payment_preimage` that will be given in return for payment. - MUST include either exactly one `d` or exactly one `h` field. @@ -191,8 +192,8 @@ A writer: - MUST specify the most-preferred field first, followed by less-preferred fields, in order. A reader: - - MUST skip over unknown fields, OR an `f` field with unknown `version`, OR `p`, `h`, or - `n` fields that do NOT have `data_length`s of 52, 52, or 53, respectively. + - MUST skip over unknown fields, OR an `f` field with unknown `version`, OR `p`, `h`, `s` or + `n` fields that do NOT have `data_length`s of 52, 52, 52 or 53, respectively. - if the `9` field contains unknown _odd_ bits that are non-zero: - MUST ignore the bit. - if the `9` field contains unknown _even_ bits that are non-zero: @@ -202,6 +203,8 @@ A reader: description. - if a valid `n` field is provided: - MUST use the `n` field to validate the signature instead of performing signature recovery. + - if there is a valid `s` field: + - MUST use that as [`payment_secret`](04-onion-routing.md#tlv_payload-payload-format) ### Rationale @@ -279,6 +282,34 @@ The field is big-endian. The least-significant bit is numbered 0, which is _even_, and the next most significant bit is numbered 1, which is _odd_. +Note that the `payment_secret` feature probing attacks from nodes +along the path, but only if made compulsory: yet doing so will break +older clients which do not understand the feature. + +### Requirements + +A writer: + - if `payment_secret` feature is set: + - MUST include an `s` field. + - otherwise: + - MUST NOT include an `s` field. + - if the `payment_secret` field is required in the onion: + - MUST set the even feature `payment_secret`. + - If the final node supports [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments): + - MUST set the `basic_mpp` feature. + - Otherwise: + - MUST NOT set the `basic_mpp` feature. + - if it sets either `payment_secret` or `basic_mpp` features: + - MUST set the `var_onion_optin` feature. + - MUST set `var_onion_optin` if and only if it supports that feature. + +A reader: + - if the `basic_mpp` feature is offered in the invoice: + - MAY pay using [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments). + - otherwise: + - MUST NOT use [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments). + + # Payer / Payee Interactions These are generally defined by the rest of the Lightning BOLT series, @@ -318,7 +349,7 @@ https://github.com/rustyrussell/lightning-payencode # Examples -NB: all the following examples are signed with `priv_key`=`e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734`. +NB: all the following examples are signed with `priv_key`=`e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734`. Also, the first 9 examples are legacy: modern invoices have an `s` field. > ### Please make a donation of any amount using payment_hash 0001020304050607080900010203040506070809000102030405060708090102 to me @03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad > lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w @@ -535,8 +566,8 @@ Breakdown: * `6c6e626332306d0b25fe64570d0e496dbd9f8b0d000dbb44824f751380da37c6dba89b14f6f92047d63f576e304021a00008101820283038404800081018202830384048000810182028303840480810243500c318a1e0a628b34025e8c9019ab6d09b64c2b3c66a693d0dc63194b02481931000` hex of data for signing (prefix + data after separator up to the start of the signature) * `399a8b167029fda8564fd2e99912236b0b8017e7d17e416ae17307812c92cf42` hex of SHA256 of the preimage -> ### Please send $30 for coffee beans to the same peer, which supports features 1 and 9 -> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9qzsze992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq73t7cl +> ### Please send $30 for coffee beans to the same peer, which supports features 15 and 99, using secret 0x1111111111111111111111111111111111111111111111111111111111111111 +> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sqdkcy8h Breakdown: @@ -548,14 +579,17 @@ Breakdown: * `d`: short description * `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) * `vdhkven9v5sxyetpdees`: 'coffee beans' +* `s`: payment secret + * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52) + * `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: 0x1111111111111111111111111111111111111111111111111111111111111111 * `9`: features - * `qz`: `data_length` (`q` = 0, `z` = 2; 0 * 32 + 2 == 2) - * `sz`: b1000000010 -* `e992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq`: signature -* `73t7cl`: Bech32 checksum + * `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) 4 + * `sqqqqqqqqqqqqqqqpqqq`: b1000....00001000000000000000 +* `pqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sq`: signature +* `dkcy8h`: Bech32 checksum -> # Same, but using invalid unknown feature 100 -> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9q4pqqqqqqqqqqqqqqqqqqszk3ed62snp73037h4py4gry05eltlp0uezm2w9ajnerhmxzhzhsu40g9mgyx5v3ad4aqwkmvyftzk4k9zenz90mhjcy9hcevc7r3lx2sphzfxz7 +> # Same, but adding invalid unknown feature 100 +> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqqqqu7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq9wq7td Breakdown: @@ -567,11 +601,14 @@ Breakdown: * `d`: short description * `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) * `vdhkven9v5sxyetpdees`: 'coffee beans' +* `s`: payment secret + * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52) + * `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: 0x1111111111111111111111111111111111111111111111111111111111111111 * `9`: features * `q4`: `data_length` (`q` = 0, `4` = 21; 0 * 32 + 21 == 21) - * `pqqqqqqqqqqqqqqqqqqsz`: b00001...(90 zeroes)...1000000010 -* `k3ed62snp73037h4py4gry05eltlp0uezm2w9ajnerhmxzhzhsu40g9mgyx5v3ad4aqwkmvyftzk4k9zenz90mhjcy9hcevc7r3lx2sp`: signature -* `hzfxz7`: Bech32 checksum + * `psqqqqqqqqqqqqqqqpqqqq`: b000011000....00001000000000000000 +* `u7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq`: signature +* `9wq7td`: Bech32 checksum # Authors From 4c3d01616d8e7c1c39212f97562964eceb769c08 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 26 Nov 2019 13:48:56 +1030 Subject: [PATCH 013/103] BOLT 4: Multi-part payments. This also defines the TLV format for payment_secret; the two are intertwined. Signed-off-by: Rusty Russell --- 04-onion-routing.md | 119 ++++++++++++++++++++++++++++++++++++++--- 11-payment-encoding.md | 2 +- 2 files changed, 113 insertions(+), 8 deletions(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index 5944dc4ea..c8609db95 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -250,18 +250,111 @@ This is a more flexible format, which avoids the redundant `short_channel_id` fi 1. type: 6 (`short_channel_id`) 2. data: * [`short_channel_id`:`short_channel_id`] + 1. type: 8 (`payment_data`) + 2. data: + * [`32*byte`:`payment_secret`] + * [`tu64`:`total_msat`] ### Requirements The writer: - - MUST include `amt_to_forward` and `outgoing_cltv_value` for every node. - - MUST include `short_channel_id` for every non-final node. - - MUST NOT include `short_channel_id` for the final node. + - Unless `node_announcement`, `init` message or the [BOLT #11](11-payment-encoding.md#tagged-fields) offers feature `var_onion_optin`: + - MUST use the legacy payload format instead. + - For every node: + - MUST include `amt_to_forward` and `outgoing_cltv_value`. + - For every non-final node: + - MUST include `short_channel_id` + - MUST NOT include `payment_data` + - For the final node: + - MUST NOT include `short_channel_id` + - if the recipient provided `payment_secret`: + - MUST include `payment_data` + - MUST set `payment_secret` to the one provided + - MUST set `total_msat` to the total amount it will send The reader: - MUST return an error if `amt_to_forward` or `outgoing_cltv_value` are not present. + - if it is the final node: + - MUST treat `total_msat` as if it were equal to `amt_to_forward` if it + is not present. + +The requirements for the contents of these fields are specified [above](#legacy-hop_data-payload-format) +and [below](#basic-multi-part-payments). + +### Basic Multi-Part Payments + +An HTLC may be part of a larger "multi-part" payment: such +"base" atomic multipath payments will use the same `payment_hash` for +all paths. + +Note that `amt_to_forward` is the amount for this HTLC only: a +`total_msat` field containing a greater value is a promise by the +ultimate sender that the rest of the payment will follow in succeeding +HTLCs; we call these outstanding HTLCs which have the same preimage, +an "HTLC set". + +#### Requirements -The requirements for the contents of these fields are specified [above](#legacy-hop_data-payload-format). +The writer: + - if the invoice offers the `basic_mpp` feature: + - MAY send more than one HTLC to pay the invoice. + - MUST use the same `payment_hash` on all HTLCs in the set. + - SHOULD send all payments at approximately the same time. + - SHOULD try to use diverse paths to the recipient for each HTLC. + - SHOULD retry and/or re-divide HTLCs which fail. + - if the invoice specifies an `amount`: + - MUST set `total_msat` to at least that `amount`, and less + than or equal to twice `amount`. + - otherwise: + - MUST set `total_msat` to the amount it wishes to pay. + - MUST ensure that the total `amount_msat` of the HTLC set which arrives at the payee + is equal to `total_msat`. + - MUST NOT send another HTLC if the total `amount_msat` of the HTLC set is already greater or equal to `total_msat`. + - otherwise: + - MUST set `total_msat` equal to `amt_to_forward`. + +The final node: + - MUST fail the HTLC if dictated by Requirements under [Failure Messages](#failure-messages) + - Note: "amount paid" specified there is the `total_msat` field. + - if it does not support `basic_mpp`: + - MUST fail the HTLC if `total_msat` is not exactly equal to `amt_to_forward`. + - otherwise, if it supports `basic_mpp`: + - MUST add it to the HTLC set corresponding to that `payment_hash`. + - SHOULD fail the entire HTLC set if `total_msat` is not the same for + all HTLCs in the set. + - if the total `amount_msat` of this HTLC set equals `total_msat`: + - SHOULD fulfill all HTLCs in the HTLC set + - otherwise, if the total `amount_msat` of this HTLC set is less than + `total_msat`: + - MUST NOT fulfill any HTLCs in the HTLC set + - MUST fail all HTLCs in the HTLC set after some reasonable timeout. + - SHOULD wait for at least 60 seconds after the initial HTLC. + - SHOULD use `mpp_timeout` for the failure message. + - if it fulfills any HTLCs in the HTLC set: + - MUST fulfill the entire HTLC set. + +#### Rationale + +If `basic_mpp` is present it causes a delay to allow other partial +payments to combine. The total amount must be sufficient for the +desired payment, just as it must be for single payments. But this must +be reasonably bounded to avoid a denial-of-service. + +Because invoices do not necessarily specify an amount, and because +payers can add noise to the final amount, the total amount must be +sent explicitly. The requirements allow exceeding this slightly, as +it simplifies adding noise to the amount when splitting, as well as +scenarios in which the senders are genuinely independent (friends +splitting a bill, for example). + +The restriction on sending an HTLC once the set is over the agreed total prevents the preimage being released before all +the partial payments have arrived: that would allow any intermediate +node to immediately claim any outstanding partial payments. + +An implementation may choose not to fulfill an HTLC set which +otherwise meets the amount criterion (eg. some other failure, or +invoice timeout), however if it were to fulfill only some of them, +intermediary nodes could simply claim the remaining ones. # Accepting and Forwarding a Payment @@ -315,6 +408,8 @@ using an alternate channel. When building the route, the origin node MUST use a payload for the final node with the following values: +* `payment_secret`: set to the payment secret specified by the recipient (e.g. + `payment_secret` from a [BOLT #11](11-payment-encoding.md) payment invoice) * `outgoing_cltv_value`: set to the final expiry specified by the recipient (e.g. `min_final_cltv_expiry` from a [BOLT #11](11-payment-encoding.md) payment invoice) * `amt_to_forward`: set to the final amount specified by the recipient (e.g. `amount` @@ -829,9 +924,10 @@ handling by the processing node. * [`u64`:`htlc_msat`] * [`u32`:`height`] -The `payment_hash` is unknown to the final node, the amount for that -`payment_hash` is incorrect or the CLTV expiry of the htlc is too close to the -current block height for safe handling. +The `payment_hash` is unknown to the final node, the `payment_secret` doesn't +match the `payment_hash`, the amount for that `payment_hash` is incorrect or +the CLTV expiry of the htlc is too close to the current block height for safe +handling. The `htlc_msat` parameter is superfluous, but left in for backwards compatibility. The value of `htlc_msat` always matches the amount specified in @@ -887,6 +983,11 @@ or is incomplete. If the failure can be narrowed down to a specific tlv type in the payload, the erring node may include that `type` and its byte `offset` in the decrypted byte stream. +1. type: 23 (`mpp_timeout`) + +The complete amount of the multi-part payment was not received within a +reasonable time. + ### Requirements An _erring node_: @@ -954,6 +1055,10 @@ An _intermediate hop_ MUST NOT, but the _final node_: - if the payment hash has already been paid: - MAY treat the payment hash as unknown. - MAY succeed in accepting the HTLC. + - if the `payment_secret` doesn't match the expected value for that `payment_hash`, + or the `payment_secret` is required and is not present: + - MUST fail the HTLC. + - MUST return an `incorrect_or_unknown_payment_details` error. - if the amount paid is less than the amount expected: - MUST fail the HTLC. - MUST return an `incorrect_or_unknown_payment_details` error. diff --git a/11-payment-encoding.md b/11-payment-encoding.md index 9404c1c7b..b6c16a7ea 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -282,7 +282,7 @@ The field is big-endian. The least-significant bit is numbered 0, which is _even_, and the next most significant bit is numbered 1, which is _odd_. -Note that the `payment_secret` feature probing attacks from nodes +Note that the `payment_secret` feature prevents probing attacks from nodes along the path, but only if made compulsory: yet doing so will break older clients which do not understand the feature. From 6ad8ee4cc46bcda2506747656e03c54bec095258 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 4 Dec 2019 12:52:02 +1030 Subject: [PATCH 014/103] BOLT 4/11: require payment_secret for multi-part payments. This means the BOLT11 invoice must offer it (we already say it must set the field if it offers it), and that the receiving node must require it (again, we already say it must check it if it requires it). Without the payment_secret, MPP payments are especially vulnerable to probing attacks: unlike normal payments (with amounts) they can be detected with 1msat payment probes. Signed-off-by: Rusty Russell --- 04-onion-routing.md | 2 ++ 11-payment-encoding.md | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index c8609db95..a0655f591 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -310,6 +310,7 @@ The writer: - MUST ensure that the total `amount_msat` of the HTLC set which arrives at the payee is equal to `total_msat`. - MUST NOT send another HTLC if the total `amount_msat` of the HTLC set is already greater or equal to `total_msat`. + - MUST include `payment_secret`. - otherwise: - MUST set `total_msat` equal to `amt_to_forward`. @@ -330,6 +331,7 @@ The final node: - MUST fail all HTLCs in the HTLC set after some reasonable timeout. - SHOULD wait for at least 60 seconds after the initial HTLC. - SHOULD use `mpp_timeout` for the failure message. + - MUST require `payment_secret` for all HTLCs in the set. - if it fulfills any HTLCs in the HTLC set: - MUST fulfill the entire HTLC set. diff --git a/11-payment-encoding.md b/11-payment-encoding.md index b6c16a7ea..e6df498bf 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -284,7 +284,10 @@ which is _odd_. Note that the `payment_secret` feature prevents probing attacks from nodes along the path, but only if made compulsory: yet doing so will break -older clients which do not understand the feature. +older clients which do not understand the feature. It is compulsory +for `basic_mpp` however, as that is also a recent feature, and makes +nodes more vulnerable to probing attacks as there is no lower-bound +on the amount sent. ### Requirements @@ -297,9 +300,10 @@ A writer: - MUST set the even feature `payment_secret`. - If the final node supports [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments): - MUST set the `basic_mpp` feature. + - MUST set the `payment_secret` feature. - Otherwise: - MUST NOT set the `basic_mpp` feature. - - if it sets either `payment_secret` or `basic_mpp` features: + - if it sets the `payment_secret` feature: - MUST set the `var_onion_optin` feature. - MUST set `var_onion_optin` if and only if it supports that feature. From 44c5fa1c7a42d5722d7be91c18c149e7f039e24a Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 24 Dec 2019 13:29:37 -0500 Subject: [PATCH 015/103] Resolve conflict between BOLT 4&9 re: var_onion_optin context BOLT 4 explicitly indicates var_onion_optin may appear in a BOLT 11 invoice, however, BOLT 9 only indicates it is available in init and node_announcement contextx. Resolve this conflict in favor of BOLT 4 as there doesn't seem to be much reason to *not* allow it in BOLT 11 invoices. --- 09-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09-features.md b/09-features.md index b05d83557..c0948c506 100644 --- a/09-features.md +++ b/09-features.md @@ -32,7 +32,7 @@ The Context column decodes as follows: | 3 | `initial_routing_sync` | Sending node needs a complete routing information dump | I | [BOLT #7][bolt07-sync] | | 4/5 | `option_upfront_shutdown_script` | Commits to a shutdown scriptpubkey when opening channel | IN | [BOLT #2][bolt02-open] | | 6/7 | `gossip_queries` | More sophisticated gossip control | IN | [BOLT #7][bolt07-query] | -| 8/9 | `var_onion_optin` | Requires/supports variable-length routing onion payloads | IN | [Routing Onion Specification][bolt04] | +| 8/9 | `var_onion_optin` | Requires/supports variable-length routing onion payloads | IN9 | [Routing Onion Specification][bolt04] | | 10/11 | `gossip_queries_ex` | Gossip queries can include additional information | IN | [BOLT #7][bolt07-query] | | 12/13| `option_static_remotekey` | Static key for remote output | IN | [BOLT #3](03-transactions.md) | | 14/15 | `payment_secret` | Node supports `payment_secret` field | IN9 | [Routing Onion Specification][bolt04] | From 5abee4d362b89cdd73f276032d14e88e295d32c3 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 24 Dec 2019 13:45:30 -0500 Subject: [PATCH 016/103] Do not allow routing to a node with unkown feature bits set. This appears to have been an oversight in the flat features spec, and is somewhat implicitly relied on for several new feature bits - if var_onion_optin is set on a node_announcement (its not allowed on a channel_announcement), then trying to route through that node using the pre-tlv formt is somewhat nonsensical, and should be forbidden. --- 07-routing-gossip.md | 3 +++ 09-features.md | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/07-routing-gossip.md b/07-routing-gossip.md index ab4ece066..6ae579d8a 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -323,6 +323,9 @@ any future fields appended to the end): - MUST NOT process the message further. - if `features` field contains _unknown even bits_: - SHOULD NOT connect to the node. + - Unless paying a [BOLT #11](11-payment-encoding.md) invoice which does not + have the same bit(s) set, MUST NOT attempt to send payments _to_ the node. + - MUST NOT route a payment _through_ the node. - SHOULD ignore the first `address descriptor` that does NOT match the types defined above. - if `addrlen` is insufficient to hold the address descriptors of the diff --git a/09-features.md b/09-features.md index c0948c506..70f1899a2 100644 --- a/09-features.md +++ b/09-features.md @@ -60,6 +60,12 @@ There is no _even_ bit for `initial_routing_sync`, as there would be little point: a local node can't determine if a remote node complies, and it must interpret the flag, as defined in the initial spec. +Note that for feature flags which are available in both the `node_announcement` +and [BOLT 11](11-payment-encoding.md) invoice contexts, the features as set in +the [BOLT 11](11-payment-encoding.md) invoice should override those set in the +`node_announcement`. This keeps things consistent with the unknown features +behavior as specified in [BOLT 7](07-routing-gossip.md#the-node_announcement-message). + ![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png "License CC-BY")
This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). From f219ee048a2761a98188e5587b13f5dd7564213c Mon Sep 17 00:00:00 2001 From: ueno Date: Wed, 8 Jan 2020 18:06:04 +0900 Subject: [PATCH 017/103] #711 don't allow a "fee" for the final node. (#718) Update a requirement that was missed in #711 --- 04-onion-routing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index a0655f591..3022315ce 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -1078,7 +1078,7 @@ An _intermediate hop_ MUST NOT, but the _final node_: - if the `outgoing_cltv_value` does NOT correspond with the `cltv_expiry` from the final node's HTLC: - MUST return `final_incorrect_cltv_expiry` error. - - if the `amt_to_forward` is greater than the `incoming_htlc_amt` from the + - if the `amt_to_forward` does NOT correspond with the `incoming_htlc_amt` from the final node's HTLC: - MUST return a `final_incorrect_htlc_amount` error. From b62c8782ed1a12759896100c3b6663cbd2542e19 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 10 Jan 2020 02:45:13 -0800 Subject: [PATCH 018/103] BOLT09: fix incorrect hyperlink text for option_mpp (#725) --- 09-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/09-features.md b/09-features.md index 70f1899a2..f64087ebe 100644 --- a/09-features.md +++ b/09-features.md @@ -36,7 +36,7 @@ The Context column decodes as follows: | 10/11 | `gossip_queries_ex` | Gossip queries can include additional information | IN | [BOLT #7][bolt07-query] | | 12/13| `option_static_remotekey` | Static key for remote output | IN | [BOLT #3](03-transactions.md) | | 14/15 | `payment_secret` | Node supports `payment_secret` field | IN9 | [Routing Onion Specification][bolt04] | -| 16/17 | `basic_mpp` | Node can receive basic multi-part payments | IN9 | [BOLT #3][bolt04-mpp] | +| 16/17 | `basic_mpp` | Node can receive basic multi-part payments | IN9 | [BOLT #4][bolt04-mpp] | ## Requirements From 11f6017e84758f5fb1a046f1ee1cefc8b5f2fba7 Mon Sep 17 00:00:00 2001 From: "ZmnSCPxj, ZmnSCPxj jxPCSmnZ" Date: Sat, 11 Jan 2020 05:27:29 +0800 Subject: [PATCH 019/103] 04-onion-routing.md: Fix factual error about `final_expiry_too_soon`. (#722) As reading of commit 6729755f shows, `final_expiry_too_soon` was 17, not PERM|17. Note that because we folded a previously non-permanent failure into the now-permanent PERM|15 failure code, modifications to payment algorithms may now be needed to specificalyl detect this case, otherwise payment algorithms may give up in some edge cases where blocks are mined while payments are in-transit between sender and receiver. --- 04-onion-routing.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index 3022315ce..abf39bcc5 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -944,12 +944,15 @@ between sending a payment with the wrong final CLTV expiry and an intermediate hop delaying the payment so that the receiver's invoice CLTV delta requirement is no longer met. -Note: Originally PERM|16 (`incorrect_payment_amount`) and PERM|17 +Note: Originally PERM|16 (`incorrect_payment_amount`) and 17 (`final_expiry_too_soon`) were used to differentiate incorrect htlc parameters from unknown payment hash. Sadly, sending this response allows for probing attacks whereby a node which receives an HTLC for forwarding can check guesses as to its final destination by sending payments with the same hash but much lower values or expiry heights to potential destinations and check the response. +Care must be taken by implementations to differentiate the previously +non-permanent case for `final_expiry_too_soon` (17) from the other, permanent +failures now represented by `incorrect_or_unknown_payment_details` (PERM|15). 1. type: 18 (`final_incorrect_cltv_expiry`) 2. data: From 4c638b735387c352f697ed1ac37e6aa7a3f01bee Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 17 Jan 2020 14:53:11 -0800 Subject: [PATCH 020/103] 09+11: require transitive feature dependencies This commit: - Adds a new Dependencies column to the BOLT 9 feature table populated with existing feature dependencies. - Requires that all valid feature vectors set transitive dependencies. - Requires checking transitive dependencies when validating init messages and payment request. - Removes transitive feature requiremetns from the BOLT 11 writer, now that they are implicit by needing to comply with the BOLT 9 origin requirements. --- 01-messaging.md | 2 ++ 09-features.md | 28 +++++++++++++++++----------- 11-payment-encoding.md | 7 ++++--- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/01-messaging.md b/01-messaging.md index 7fd3e2707..b3e9343ae 100644 --- a/01-messaging.md +++ b/01-messaging.md @@ -255,6 +255,8 @@ The receiving node: - MUST ignore the bit. - upon receiving unknown _even_ feature bits that are non-zero: - MUST fail the connection. + - if the feature vector does not set all known, transitive dependencies: + - MUST fail the connection. #### Rationale diff --git a/09-features.md b/09-features.md index f64087ebe..74e1c7925 100644 --- a/09-features.md +++ b/09-features.md @@ -26,17 +26,17 @@ The Context column decodes as follows: * `C+`: presented in the `channel_announcement` message, but always even (required). * `9`: presented in [BOLT 11](11-payment-encoding.md) invoices. -| Bits | Name | Description | Context | Link | -|-------|----------------------------------|-----------------------------------------------------------|----------|---------------------------------------| -| 0/1 | `option_data_loss_protect` | Requires or supports extra `channel_reestablish` fields | IN | [BOLT #2][bolt02-retransmit] | -| 3 | `initial_routing_sync` | Sending node needs a complete routing information dump | I | [BOLT #7][bolt07-sync] | -| 4/5 | `option_upfront_shutdown_script` | Commits to a shutdown scriptpubkey when opening channel | IN | [BOLT #2][bolt02-open] | -| 6/7 | `gossip_queries` | More sophisticated gossip control | IN | [BOLT #7][bolt07-query] | -| 8/9 | `var_onion_optin` | Requires/supports variable-length routing onion payloads | IN9 | [Routing Onion Specification][bolt04] | -| 10/11 | `gossip_queries_ex` | Gossip queries can include additional information | IN | [BOLT #7][bolt07-query] | -| 12/13| `option_static_remotekey` | Static key for remote output | IN | [BOLT #3](03-transactions.md) | -| 14/15 | `payment_secret` | Node supports `payment_secret` field | IN9 | [Routing Onion Specification][bolt04] | -| 16/17 | `basic_mpp` | Node can receive basic multi-part payments | IN9 | [BOLT #4][bolt04-mpp] | +| Bits | Name | Description | Context | Dependencies | Link | +|-------|----------------------------------|-----------------------------------------------------------|----------|-------------------|---------------------------------------| +| 0/1 | `option_data_loss_protect` | Requires or supports extra `channel_reestablish` fields | IN | | [BOLT #2][bolt02-retransmit] | +| 3 | `initial_routing_sync` | Sending node needs a complete routing information dump | I | | [BOLT #7][bolt07-sync] | +| 4/5 | `option_upfront_shutdown_script` | Commits to a shutdown scriptpubkey when opening channel | IN | | [BOLT #2][bolt02-open] | +| 6/7 | `gossip_queries` | More sophisticated gossip control | IN | | [BOLT #7][bolt07-query] | +| 8/9 | `var_onion_optin` | Requires/supports variable-length routing onion payloads | IN9 | | [Routing Onion Specification][bolt04] | +| 10/11 | `gossip_queries_ex` | Gossip queries can include additional information | IN | `gossip_queries` | [BOLT #7][bolt07-query] | +| 12/13 | `option_static_remotekey` | Static key for remote output | IN | | [BOLT #3](03-transactions.md) | +| 14/15 | `payment_secret` | Node supports `payment_secret` field | IN9 | `var_onion_optin` | [Routing Onion Specification][bolt04] | +| 16/17 | `basic_mpp` | Node can receive basic multi-part payments | IN9 | `payment_secret` | [BOLT #4][bolt04-mpp] | ## Requirements @@ -49,6 +49,7 @@ The origin node: unless indicated that it must set the odd feature bit instead. * MUST NOT set feature bits it does not support. * MUST NOT set feature bits in fields not specified by the table above. + * MUST set all transitive feature dependencies. The requirements for receiving specific bits are defined in the linked sections in the table above. The requirements for feature bits that are not defined @@ -66,6 +67,11 @@ the [BOLT 11](11-payment-encoding.md) invoice should override those set in the `node_announcement`. This keeps things consistent with the unknown features behavior as specified in [BOLT 7](07-routing-gossip.md#the-node_announcement-message). +The origin must set all transitive feature dependencies in order to create a +well-formed feature vector. By validating all known dependencies up front, this +simplifies logic gated on a single feature bit; the feature's dependencies are +known to be set, and do not need to be validated at every feature gate. + ![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png "License CC-BY")
This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). diff --git a/11-payment-encoding.md b/11-payment-encoding.md index e6df498bf..8254a7da6 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -292,6 +292,8 @@ on the amount sent. ### Requirements A writer: + - MUST set the `9` field to a feature vector compliant with the + [BOLT 9 origin node requirements](09-features.md#requirements). - if `payment_secret` feature is set: - MUST include an `s` field. - otherwise: @@ -300,14 +302,13 @@ A writer: - MUST set the even feature `payment_secret`. - If the final node supports [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments): - MUST set the `basic_mpp` feature. - - MUST set the `payment_secret` feature. - Otherwise: - MUST NOT set the `basic_mpp` feature. - - if it sets the `payment_secret` feature: - - MUST set the `var_onion_optin` feature. - MUST set `var_onion_optin` if and only if it supports that feature. A reader: + - if the feature vector does not set all known, transitive feature dependencies: + - MUST NOT attempt the payment. - if the `basic_mpp` feature is offered in the invoice: - MAY pay using [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments). - otherwise: From 1259f8f0db95e2b5498af1fcec7ec0d40e71e67d Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 17 Jan 2020 14:53:13 -0800 Subject: [PATCH 021/103] BOLT11: set TLV bit in payment secret test vectors --- 11-payment-encoding.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/11-payment-encoding.md b/11-payment-encoding.md index 8254a7da6..4a96fd53a 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -571,8 +571,8 @@ Breakdown: * `6c6e626332306d0b25fe64570d0e496dbd9f8b0d000dbb44824f751380da37c6dba89b14f6f92047d63f576e304021a00008101820283038404800081018202830384048000810182028303840480810243500c318a1e0a628b34025e8c9019ab6d09b64c2b3c66a693d0dc63194b02481931000` hex of data for signing (prefix + data after separator up to the start of the signature) * `399a8b167029fda8564fd2e99912236b0b8017e7d17e416ae17307812c92cf42` hex of SHA256 of the preimage -> ### Please send $30 for coffee beans to the same peer, which supports features 15 and 99, using secret 0x1111111111111111111111111111111111111111111111111111111111111111 -> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sqdkcy8h +> ### Please send $30 for coffee beans to the same peer, which supports features 9, 15 and 99, using secret 0x1111111111111111111111111111111111111111111111111111111111111111 +> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqsq67gye39hfg3zd8rgc80k32tvy9xk2xunwm5lzexnvpx6fd77en8qaq424dxgt56cag2dpt359k3ssyhetktkpqh24jqnjyw6uqd08sgptq44qu Breakdown: @@ -588,13 +588,13 @@ Breakdown: * `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52) * `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: 0x1111111111111111111111111111111111111111111111111111111111111111 * `9`: features - * `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) 4 - * `sqqqqqqqqqqqqqqqpqqq`: b1000....00001000000000000000 -* `pqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sq`: signature -* `dkcy8h`: Bech32 checksum + * `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) + * `sqqqqqqqqqqqqqqqpqsq`: b1000....00001000001000000000 +* `67gye39hfg3zd8rgc8032tvy9xk2xunwm5lzexnvpx6fd77en8qaq424dxgt56cag2dpt359k3ssyhetktkpqh24jqnjyw6uqd08sgp`: signature +* `tq44qu`: Bech32 checksum > # Same, but adding invalid unknown feature 100 -> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqqqqu7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq9wq7td +> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqsqq40wa3khl49yue3zsgm26jrepqr2eghqlx86rttutve3ugd05em86nsefzh4pfurpd9ek9w2vp95zxqnfe2u7ckudyahsa52q66tgzcp6t2dyk Breakdown: @@ -611,9 +611,9 @@ Breakdown: * `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: 0x1111111111111111111111111111111111111111111111111111111111111111 * `9`: features * `q4`: `data_length` (`q` = 0, `4` = 21; 0 * 32 + 21 == 21) - * `psqqqqqqqqqqqqqqqpqqqq`: b000011000....00001000000000000000 -* `u7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq`: signature -* `9wq7td`: Bech32 checksum + * `psqqqqqqqqqqqqqqqpqsqq`: b000011000....00001000001000000000 +* `40wa3khl49yue3zsgm26jrepqr2eghqlx86rttutve3ugd05em86nsefzh4pfurpd9ek9w2vp95zxqnfe2u7ckudyahsa52q66tgzcp`: signature +* `6t2dyk`: Bech32 checksum # Authors From 53653e5c52e50e51f764fd8726a8d106c43c0b8b Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 17 Jan 2020 14:53:14 -0800 Subject: [PATCH 022/103] BOLT 04: add missing subsections to ToC --- 04-onion-routing.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index abf39bcc5..95ed79857 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -48,7 +48,12 @@ A node: * [Key Generation](#key-generation) * [Pseudo Random Byte Stream](#pseudo-random-byte-stream) * [Packet Structure](#packet-structure) + * [Legacy HopData Payload Format](#legacy-hop_data-payload-format) + * [TLV Payload Format](#tlv_payload-format) + * [Basic Multi-Part Payments](#basic-multi-part-payments) + * [Accepting and Forwarding a Payment](#accepting-and-forwarding-a-payment) * [Payload for the Last Node](#payload-for-the-last-node) + * [Non-strict Forwarding](#non-strict-forwarding) * [Shared Secret](#shared-secret) * [Blinding Ephemeral Keys](#blinding-ephemeral-keys) * [Packet Construction](#packet-construction) @@ -235,7 +240,7 @@ When forwarding HTLCs, nodes MUST construct the outgoing HTLC as specified within `hop_data` above; otherwise, deviation from the specified HTLC parameters may lead to extraneous routing failure. -### `tlv_payload` payload format +### `tlv_payload` format This is a more flexible format, which avoids the redundant `short_channel_id` field for the final node. From c3a8e5e1a73216d0c58393e7ea6e0741a0f87472 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 17 Jan 2020 14:53:15 -0800 Subject: [PATCH 023/103] BOLT11: simplify existing writer feature requirements As a final step, we now can remove several of the BOLT 11 writer's requirements now that it builds on BOLT 9's, particularly: - setting the even bit if a feature is required. - only setting a feature if the node supports a given feature. The lone requirement that remains pertains to setting the `s` value if and only if the `payment_secret` feature is set. --- 11-payment-encoding.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/11-payment-encoding.md b/11-payment-encoding.md index 4a96fd53a..86996eda8 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -294,17 +294,7 @@ on the amount sent. A writer: - MUST set the `9` field to a feature vector compliant with the [BOLT 9 origin node requirements](09-features.md#requirements). - - if `payment_secret` feature is set: - - MUST include an `s` field. - - otherwise: - - MUST NOT include an `s` field. - - if the `payment_secret` field is required in the onion: - - MUST set the even feature `payment_secret`. - - If the final node supports [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments): - - MUST set the `basic_mpp` feature. - - Otherwise: - - MUST NOT set the `basic_mpp` feature. - - MUST set `var_onion_optin` if and only if it supports that feature. + - MUST set an `s` field if and only if the `payment_secret` feature is set. A reader: - if the feature vector does not set all known, transitive feature dependencies: From caca4375e610471926442374d01bc97e27869021 Mon Sep 17 00:00:00 2001 From: Bastien Teinturier Date: Thu, 21 Nov 2019 11:00:33 +0100 Subject: [PATCH 024/103] BOLT 1: Define custom message type range --- 01-messaging.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/01-messaging.md b/01-messaging.md index b3e9343ae..4b9a7e0da 100644 --- a/01-messaging.md +++ b/01-messaging.md @@ -51,12 +51,13 @@ A receiving node: - upon receiving a message of _even_, unknown type: - MUST fail the channels. -The messages are grouped logically into four groups, ordered by the most significant bit that is set: +The messages are grouped logically into five groups, ordered by the most significant bit that is set: - Setup & Control (types `0`-`31`): messages related to connection setup, control, supported features, and error reporting (described below) - Channel (types `32`-`127`): messages used to setup and tear down micropayment channels (described in [BOLT #2](02-peer-protocol.md)) - Commitment (types `128`-`255`): messages related to updating the current commitment transaction, which includes adding, revoking, and settling HTLCs as well as updating fees and exchanging signatures (described in [BOLT #2](02-peer-protocol.md)) - Routing (types `256`-`511`): messages containing node and channel announcements, as well as any active route exploration (described in [BOLT #7](07-routing-gossip.md)) + - Custom (types `32768`-`65535`): experimental and application-specific messages The size of the message is required by the transport layer to fit into a 2-byte unsigned int; therefore, the maximum possible size is 65535 bytes. @@ -66,6 +67,13 @@ A node: - MUST fail the channels. - that negotiates an option in this specification: - MUST include all the fields annotated with that option. + - When defining custom messages: + - SHOULD pick a random `type` to avoid collision with other custom types. + - SHOULD pick a `type` that doesn't conflict with other experiments listed in [this issue](https://github.com/lightningnetwork/lightning-rfc/issues/716). + - SHOULD pick an odd `type` identifiers when regular nodes should ignore the + additional data. + - SHOULD pick an even `type` identifiers when regular nodes should reject + the message and close the connection. ### Rationale @@ -100,7 +108,7 @@ A `tlv_record` represents a single field, encoded in the form: A `varint` is a variable-length, unsigned integer encoding using the [BigSize](#appendix-a-bigsize-test-vectors) format, which resembles the bitcoin CompactSize encoding but uses big-endian for multi-byte values rather than -little-endian. +little-endian. A `tlv_stream` is a series of (possibly zero) `tlv_record`s, represented as the concatenation of the encoded `tlv_record`s. When used to extend existing From 798ff4bdec8381f61f1f38d0680c2979bdf8d4df Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 21 Jan 2020 13:57:40 +0100 Subject: [PATCH 025/103] fixup! Specify that resolution of amount is msat --- 11-payment-encoding.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/11-payment-encoding.md b/11-payment-encoding.md index 66da25a28..e5ba6844f 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -64,7 +64,7 @@ A writer: - if a specific minimum `amount` is required for successful payment: - MUST include that `amount`. - MUST encode `amount` as a positive decimal integer with no leading 0s. - - MUST request `amount` divisible by ten if the `p` multiplier is used. + - If the is `p` multiplier is used the `amount` the last decimal MUST be `0`. - SHOULD use the shortest representation possible, by using the largest multiplier or omitting the multiplier. @@ -90,6 +90,9 @@ Donation addresses often don't have an associated amount, so `amount` is optional in that case. Usually a minimum payment is required for whatever is being offered in return. +The `p` multiplier would allow to specify sub-millisatoshi amounts, which cannot be transferred on the network, since HTLCs are denominated in millisatoshis. +Requiring a trailing `0` decimal ensures that the `amount` represents an integer number of millisatoshis. + # Data Part The data part of a Lightning invoice consists of multiple sections: From 29f138699515d896b283da6fa53a5e16205eb2aa Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 21 Jan 2020 14:01:04 +0100 Subject: [PATCH 026/103] fixup! Specify that resolution of amount is msat --- 11-payment-encoding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/11-payment-encoding.md b/11-payment-encoding.md index e5ba6844f..54487e2b6 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -64,7 +64,7 @@ A writer: - if a specific minimum `amount` is required for successful payment: - MUST include that `amount`. - MUST encode `amount` as a positive decimal integer with no leading 0s. - - If the is `p` multiplier is used the `amount` the last decimal MUST be `0`. + - If the `p` multiplier is used the `amount` the last decimal MUST be `0`. - SHOULD use the shortest representation possible, by using the largest multiplier or omitting the multiplier. From 8dd0b75809c9a7498bb9031a6674e5f58db509f4 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 5 Nov 2019 18:26:54 -0800 Subject: [PATCH 027/103] BOLT-04: modify Sphinx packet construction to use starting random bytes In this commit, we modify the existing instructions to create the Sphinx packet to no longer start out with a zero initialize set of 1366 bytes. Instead, we now instruct the sender to use _random_ bytes derived from a CSPRG. This fixes a recently discovered privacy leak that allows an adversarial exit hop to ascertain a lower bound on the true path length. Note that this doesn't affect packet processing, so this is a backwards compatible change. Only clients need to update in order to avoid this privacy leak. After this change is applied, the test vectors as is don't match the spec, as they're created using the original all zero starting bytes. We can either update these with our specified set of random bytes, or leave them as is, as they're fully deterministic as is. An alternative path would be to generate more random bytes from the shared secret as we do elsewhere (the chacha based CSPRNG). --- .aspell.en.pws | 1 + 04-onion-routing.md | 29 ++++++++++++++++++++++------- bolt04/onion-test-multi-frame.json | 2 +- bolt04/onion-test-v0.json | 12 ++++++------ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.aspell.en.pws b/.aspell.en.pws index 5ff04bfea..15b8def16 100644 --- a/.aspell.en.pws +++ b/.aspell.en.pws @@ -374,3 +374,4 @@ snprintf GitHub IRC bitmasks +CSPRNG diff --git a/04-onion-routing.md b/04-onion-routing.md index 95ed79857..9fdf357cb 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -106,14 +106,17 @@ A number of encryption and verification keys are derived from the shared secret: to obfuscate the per-hop information - _mu_: used during the HMAC generation - _um_: used during error reporting + - _pad_: use to generate random filler bytes for the starting mix-header + packet -The key generation function takes a key-type (_rho_=`0x72686F`, _mu_=`0x6d75`, -or _um_=`0x756d`) and a 32-byte secret as inputs and returns a 32-byte key. +The key generation function takes a key-type (_rho_=`0x72686F`, _mu_=`0x6d75`, +_um_=`0x756d`, or _pad_=`0x706164`) and a 32-byte secret as inputs and returns +a 32-byte key. Keys are generated by computing an HMAC (with `SHA256` as hashing algorithm) -using the appropriate key-type (i.e. _rho_, _mu_, or _um_) as HMAC-key and the -32-byte shared secret as the message. The resulting HMAC is then returned as the -key. +using the appropriate key-type (i.e. _rho_, _mu_, _um_, or _pad_) as HMAC-key +and the 32-byte shared secret as the message. The resulting HMAC is then +returned as the key. Notice that the key-type does not include a C-style `0x00`-termination-byte, e.g. the length of the _rho_ key-type is 3 bytes, not 4. @@ -506,9 +509,15 @@ The construction returns a single 1366-byte packet along with the first receivin The packet construction is performed in the reverse order of the route, i.e. the last hop's operations are applied first. -The packet is initialized with 1366 `0x00`-bytes. +The packet is initialized with 1366 _random_ bytes derived from a CSPRNG +(ChaCha20). The _pad_ key referenced above is used to extract additional random +bytes from a ChaCha20 stream, using it as a CSPRNG for this purpose. Once the +`paddingKey` has been obtained, ChaCha20 is used with an all zero nonce, to +generate 1366 random bytes. Those random bytes are then used as the starting +state of the mix-header to be created. -A filler is generated (see [Filler Generation](#filler-generation)) using the shared secret. +A filler is generated (see [Filler Generation](#filler-generation)) using the +shared secret. For each hop in the route, in reverse order, the sender applies the following operations: @@ -573,6 +582,12 @@ func NewOnionPacket(paymentPath []*btcec.PublicKey, sessionKey *btcec.PrivateKey // Allocate and initialize fields to zero-filled slices var mixHeader [routingInfoSize]byte var nextHmac [hmacSize]byte + + // Our starting packet needs to be filled out with random bytes, we + // generate some determinstically using the session private key. + paddingKey := generateKey("pad", sessionKey.Serialize() + paddingBytes := generateCipherStream(paddingKey, routingInfoSize) + copy(mixHeader[:], paddingBytes) // Compute the routing information for each hop along with a // MAC of the routing information using the shared key for that hop. diff --git a/bolt04/onion-test-multi-frame.json b/bolt04/onion-test-multi-frame.json index 495de9e13..5d20be295 100644 --- a/bolt04/onion-test-multi-frame.json +++ b/bolt04/onion-test-multi-frame.json @@ -31,7 +31,7 @@ } ] }, - "onion": "0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619e5f14350c2a76fc232b5e46d421e9615471ab9e0bc887beff8c95fdb878f7b3a71a060daf367132b378b3a3883c0e2c0e026b8900b2b5cdbc784e1a3bb913f88a9c50f7d61ab590531cf08000178a333a347f8b4072ed056f820f77774345e183a342ec4729f3d84accf515e88adddb85ecc08daba68404bae9a8e8d7178977d7094a1ae549f89338c0777551f874159eb42d3a59fb9285ad4e24883f27de23942ec966611e99bee1cee503455be9e8e642cef6cef7b9864130f692283f8a973d47a8f1c1726b6e59969385975c766e35737c8d76388b64f748ee7943ffb0e2ee45c57a1abc40762ae598723d21bd184e2b338f68ebff47219357bd19cd7e01e2337b806ef4d717888e129e59cd3dc31e6201ccb2fd6d7499836f37a993262468bcb3a4dcd03a22818aca49c6b7b9b8e9e870045631d8e039b066ff86e0d1b7291f71cefa7264c70404a8e538b566c17ccc5feab231401e6c08a01bd5edfc1aa8e3e533b96e82d1f91118d508924b923531929aea889fcdf050597c681185f336b1da63b0939aa2b7c50b21b5eb7b6ad66c81fab98a3cdf73f658149e7e9ced4edde5d38c9b8f92e16f6b4ab13d7fca6a0e4ecc9f9de611a90da6e99c39551094c56e3196f282c5dffd9fc4b2fc12f3bca8e6fe47eb45fbdd3be21a8a8d200797eae3c9a0497132f92410d804977408494dff49dd3d8bce248e0b74fd9e6f0f7102c25ddfa02bd9ad9f746abbfa337ef811d5345a9e16b60de1767b209645ba40bd1f9a5f75bc04feca9b27c5554be4fe83fac2cb83aa447a817bb85ae966c68b420063833fada375e2f515965e687a45699632902672c654d1d18d7bcbf55e8fa57f63f2da449f8e1e606e8722df081e5f193fc4179feb99ad22819afdeef211f7c54afdba92aeef0c00b7bc2b65a4813c01f907a8377585708f2d4c940a25328e585714c8ded0a9a4d7a6de1027c1cb7a0198cd3db68b58c0704dfd0cfbe624e9cd18cc0ae5d96697bb476708b9ee0403d211e64e0d5a7683a7a9a140c02f0ff1c6e67a302941b4052bdea8a63e70a3ad62c5b89c698f1fd3c7685cb49705096cad702d02d93bcb1c27a409f4c9bddec001205ca4a2740f19b50900be81c7e847f1a863deea8d35701f1355cad8db57b1d4eb2ab4e29587734785abfb46ddede71928213d7d089dfdeda052827f459f1688cc0935bd47e7bcec27427c8376dcce7e22699567c0d145f8a7db33f6758815f1f15f9f7a9760dec4f34ae095edda4c64e9735bdd029c4e32c2ee31ba47ec5e6bdb97813d52dbd15b4e0b7a2c7f790ae64104d99f38c127f0a093288fa34144adb16b8968d4fa7656fcec99de8503dd46d3b03620a71c7cd085364abd30dccf7fbda25a1cdc102600149c9af1c97aa0372cd2e1909f28ac5c686f432b310e79528c9b8b9e8f314c1e74621ce6308ad2278b81d460892e0d9dd38b7c76d58be6dfd10ae7583ee1e7ef5b3f6f78dc60af0950df1b00cc55b6d178ba2e476bea0eaeef49323b83f05804159e7aef4eed4cc60dd07be76f067dfd0bcfb0b806b69ba921336a20c43c832d0cab8fa3ddeb29e3bf07b0d98a112eb07802756235a49d44a8b82a950d84e95e01971f0e106ccb337f07384e21620e0ad39e16ed9edca123226cf55ac44f449eeb53e38a7f27d101806e4823e4efcc887414240ee6826c4a5cb1c6443ad36ebf905a435c1d9054e54173911b17b5b40f60b3d9fd5f12eac54ca1e20191f5f18544d5fd3d665e9bcef96fb44b76110aa64d9db4c86c9513cbdad546538e8aec521fbe83ceac5e74a15629f1ed0b870a1d0d1e5680b6d6100d1bd3f3b9043bd35b8919c4088f1949b8be89e4701eb870f8ed64fafa446c78df3ea", + "onion": "0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619e5f14350c2a76fc232b5e46d421e9615471ab9e0bc887beff8c95fdb878f7b3a710f8eaf9ccc768f66bb5dec1f7827f33c43fe2ddd05614c8283aa78e9e7573f87c50f7d61ab590531cf08000178a333a347f8b4072e1cea42da7552402b10765adae3f581408f35ff0a71a34b78b1d8ecae77df96c6404bae9a8e8d7178977d7094a1ae549f89338c0777551f874159eb42d3a59fb9285ad4e24883f27de23942ec966611e99bee1cee503455be9e8e642cef6cef7b9864130f692283f8a973d47a8f1c1726b6e59969385975c766e35737c8d76388b64f748ee7943ffb0e2ee45c57a1abc40762ae598723d21bd184e2b338f68ebff47219357bd19cd7e01e2337b806ef4d717888e129e59cd3dc31e6201ccb2fd6d7499836f37a993262468bcb3a4dcd03a22818aca49c6b7b9b8e9e870045631d8e039b066ff86e0d1b7291f71cefa7264c70404a8e538b566c17ccc5feab231401e6c08a01bd5edfc1aa8e3e533b96e82d1f91118d508924b923531929aea889fcdf057f5995d9731c4bf796fb0e41c885d488dcbc68eb742e27f44310b276edc6f652658149e7e9ced4edde5d38c9b8f92e16f6b4ab13d710ee5c193921909bdd75db331cd9d7581a39fca50814ed8d9d402b86e7f8f6ac2f3bca8e6fe47eb45fbdd3be21a8a8d200797eae3c9a0497132f92410d804977408494dff49dd3d8bce248e0b74fd9e6f0f7102c25ddfa02bd9ad9f746abbfa3379834bc2380d58e9d23237821475a1874484783a15d68f47d3dc339f38d9bf925655d5c946778680fd6d1f062f84128895aff09d35d6c92cca63d3f95a9ee8f2a84f383b4d6a087533e65de12fc8dcaf85777736a2088ff4b22462265028695b37e70963c10df8ef2458756c73007dc3e544340927f9e9f5ea4816a9fd9832c311d122e9512739a6b4714bba590e31caa143ce83cb84b36c738c60c3190ff70cd9ac286a9fd2ab619399b68f1f7447be376ce884b5913c8496d01cbf7a44a60b6e6747513f69dc538f340bc1388e0fde5d0c1db50a4dcb9cc0576e0e2474e4853af9623212578d502757ffb2e0e749695ed70f61c116560d0d4154b64dcf3cbf3c91d89fb6dd004dc19588e3479fcc63c394a4f9e8a3b8b961fce8a532304f1337f1a697a1bb14b94d2953f39b73b6a3125d24f27fcd4f60437881185370bde68a5454d816e7a70d4cea582effab9a4f1b730437e35f7a5c4b769c7b72f0346887c1e63576b2f1e2b3706142586883f8cf3a23595cc8e35a52ad290afd8d2f8bcd5b4c1b891583a4159af7110ecde092079209c6ec46d2bda60b04c519bb8bc6dffb5c87f310814ef2f3003671b3c90ddf5d0173a70504c2280d31f17c061f4bb12a978122c8a2a618bb7d1edcf14f84bf0fa181798b826a254fca8b6d7c81e0beb01bd77f6461be3c8647301d02b04753b0771105986aa0cbc13f7718d64e1b3437e8eef1d319359914a7932548c91570ef3ea741083ca5be5ff43c6d9444d29df06f76ec3dc936e3d180f4b6d0fbc495487c7d44d7c8fe4a70d5ff1461d0d9593f3f898c919c363fa18341ce9dae54f898ccf3fe792136682272941563387263c51b2a2f32363b804672cc158c9230472b554090a661aa81525d11876eefdcc45442249e61e07284592f1606491de5c0324d3af4be035d7ede75b957e879e9770cdde2e1bbc1ef75d45fe555f1ff6ac296a2f648eeee59c7c08260226ea333c285bcf37a9bbfa57ba2ab8083c4be6fc2ebe279537d22da96a07392908cf22b233337a74fe5c603b51712b43c3ee55010ee3d44dd9ba82bba3145ec358f863e04bbfa53799a7a9216718fd5859da2f0deb77b8e315ad6868fdec9400f45a48e6dc8ddbaeb3", "decode": [ "4141414141414141414141414141414141414141414141414141414141414141", "4242424242424242424242424242424242424242424242424242424242424242", diff --git a/bolt04/onion-test-v0.json b/bolt04/onion-test-v0.json index e30a715bf..bf59320aa 100644 --- a/bolt04/onion-test-v0.json +++ b/bolt04/onion-test-v0.json @@ -11,7 +11,7 @@ "payload": "0000000000000000000000000000000000000000000000000000000000000000", "rhokey": "ce496ec94def95aadd4bec15cdb41a740c9f2b62347c4917325fcc6fb0453986", "mukey": "b57061dc6d0a2b9f261ac410c8b26d64ac5506cbba30267a649c28c179400eba", - "hmac": "65f21f9190c70217774a6fbaaa7d63ad64199f4664813b955cff954949076dcf" + "hmac": "b8640887e027e946df96488b47fbc4a4fadaa8beda4abe446fafea5403fae2ef" }, { "realm": 0, @@ -20,7 +20,7 @@ "payload": "0101010101010101000000000000000100000001000000000000000000000000", "rhokey": "450ffcabc6449094918ebe13d4f03e433d20a3d28a768203337bc40b6e4b2c59", "mukey": "05ed2b4a3fb023c2ff5dd6ed4b9b6ea7383f5cfe9d59c11d121ec2c81ca2eea9", - "hmac": "9b122c79c8aee73ea2cdbc22eca15bbcc9409a4cdd73d2b3fcd4fe26a492d376" + "hmac": "a93aa4f40241cef3e764e24b28570a0db39af82ab5102c3a04e51bec8cca9394" }, { "realm": 0, @@ -29,7 +29,7 @@ "payload": "0202020202020202000000000000000200000002000000000000000000000000", "rhokey": "11bf5c4f960239cb37833936aa3d02cea82c0f39fd35f566109c41f9eac8deea", "mukey": "caafe2820fa00eb2eeb78695ae452eba38f5a53ed6d53518c5c6edf76f3f5b78", - "hmac": "548e58057ab0a0e6c2d8ad8e855d89f9224279a5652895ea14f60bffb81590eb" + "hmac": "5d1b11f1efeaa9be32eb1c74b113c0b46f056bb49e2a35a51ceaece6bd31332c" }, { "realm": 0, @@ -38,7 +38,7 @@ "payload": "0303030303030303000000000000000300000003000000000000000000000000", "rhokey": "cbe784ab745c13ff5cffc2fbe3e84424aa0fd669b8ead4ee562901a4a4e89e9e", "mukey": "5052aa1b3d9f0655a0932e50d42f0c9ba0705142c25d225515c45f47c0036ee9", - "hmac": "0daed5f832ef34ea8d0d2cc0699134287a2739c77152d9edc8fe5ccce7ec838f" + "hmac": "19ca6357b5552b28e50ae226854eec874bbbf7025cf290a34c06b4eff5d2bac0" }, { "realm": 0, @@ -47,11 +47,11 @@ "payload": "0404040404040404000000000000000400000004000000000000000000000000", "rhokey": "034e18b8cc718e8af6339106e706c52d8df89e2b1f7e9142d996acf88df8799b", "mukey": "8e45e5c61c2b24cb6382444db6698727afb063adecd72aada233d4bf273d975a", - "hmac": "62cc962876e734e089e79eda497077fb411fac5f36afd43329040ecd1e16c6d9" + "hmac": "16d4553c6084b369073d259381bb5b02c16bb2c590bbd9e69346cf7ebd563229 } ] }, - "onion": "0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619e5f14350c2a76fc232b5e46d421e9615471ab9e0bc887beff8c95fdb878f7b3a71da571226458c510bbadd1276f045c21c520a07d35da256ef75b4367962437b0dd10f7d61ab590531cf08000178a333a347f8b4072e216400406bdf3bf038659793a86cae5f52d32f3438527b47a1cfc54285a8afec3a4c9f3323db0c946f5d4cb2ce721caad69320c3a469a202f3e468c67eaf7a7cda226d0fd32f7b48084dca885d15222e60826d5d971f64172d98e0760154400958f00e86697aa1aa9d41bee8119a1ec866abe044a9ad635778ba61fc0776dc832b39451bd5d35072d2269cf9b040d6ba38b54ec35f81d7fc67678c3be47274f3c4cc472aff005c3469eb3bc140769ed4c7f0218ff8c6c7dd7221d189c65b3b9aaa71a01484b122846c7c7b57e02e679ea8469b70e14fe4f70fee4d87b910cf144be6fe48eef24da475c0b0bcc6565ae82cd3f4e3b24c76eaa5616c6111343306ab35c1fe5ca4a77c0e314ed7dba39d6f1e0de791719c241a939cc493bea2bae1c1e932679ea94d29084278513c77b899cc98059d06a27d171b0dbdf6bee13ddc4fc17a0c4d2827d488436b57baa167544138ca2e64a11b43ac8a06cd0c2fba2d4d900ed2d9205305e2d7383cc98dacb078133de5f6fb6bed2ef26ba92cea28aafc3b9948dd9ae5559e8bd6920b8cea462aa445ca6a95e0e7ba52961b181c79e73bd581821df2b10173727a810c92b83b5ba4a0403eb710d2ca10689a35bec6c3a708e9e92f7d78ff3c5d9989574b00c6736f84c199256e76e19e78f0c98a9d580b4a658c84fc8f2096c2fbea8f5f8c59d0fdacb3be2802ef802abbecb3aba4acaac69a0e965abd8981e9896b1f6ef9d60f7a164b371af869fd0e48073742825e9434fc54da837e120266d53302954843538ea7c6c3dbfb4ff3b2fdbe244437f2a153ccf7bdb4c92aa08102d4f3cff2ae5ef86fab4653595e6a5837fa2f3e29f27a9cde5966843fb847a4a61f1e76c281fe8bb2b0a181d096100db5a1a5ce7a910238251a43ca556712eaadea167fb4d7d75825e440f3ecd782036d7574df8bceacb397abefc5f5254d2722215c53ff54af8299aaaad642c6d72a14d27882d9bbd539e1cc7a527526ba89b8c037ad09120e98ab042d3e8652b31ae0e478516bfaf88efca9f3676ffe99d2819dcaeb7610a626695f53117665d267d3f7abebd6bbd6733f645c72c389f03855bdf1e4b8075b516569b118233a0f0971d24b83113c0b096f5216a207ca99a7cddc81c130923fe3d91e7508c9ac5f2e914ff5dccab9e558566fa14efb34ac98d878580814b94b73acbfde9072f30b881f7f0fff42d4045d1ace6322d86a97d164aa84d93a60498065cc7c20e636f5862dc81531a88c60305a2e59a985be327a6902e4bed986dbf4a0b50c217af0ea7fdf9ab37f9ea1a1aaa72f54cf40154ea9b269f1a7c09f9f43245109431a175d50e2db0132337baa0ef97eed0fcf20489da36b79a1172faccc2f7ded7c60e00694282d93359c4682135642bc81f433574aa8ef0c97b4ade7ca372c5ffc23c7eddd839bab4e0f14d6df15c9dbeab176bec8b5701cf054eb3072f6dadc98f88819042bf10c407516ee58bce33fbe3b3d86a54255e577db4598e30a135361528c101683a5fcde7e8ba53f3456254be8f45fe3a56120ae96ea3773631fcb3873aa3abd91bcff00bd38bd43697a2e789e00da6077482e7b1b1a677b5afae4c54e6cbdf7377b694eb7d7a5b913476a5be923322d3de06060fd5e819635232a2cf4f0731da13b8546d1d6d4f8d75b9fce6c2341a71b0ea6f780df54bfdb0dd5cd9855179f602f917265f21f9190c70217774a6fbaaa7d63ad64199f4664813b955cff954949076dcf", + "onion": "0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619e5f14350c2a76fc232b5e46d421e9615471ab9e0bc887beff8c95fdb878f7b3a71e87f9aab8f6378c6ff744c1f34b393ad28d065b535c1a8668d85d3b34a1b3befd10f7d61ab590531cf08000178a333a347f8b4072e216400406bdf3bf038659793a1f9e7abc789266cc861cabd95818c0fc8efbdfdc14e3f7c2bc7eb8d6a79ef75ce721caad69320c3a469a202f3e468c67eaf7a7cda226d0fd32f7b48084dca885d014698cf05d742557763d9cb743faeae65dcc79dddaecf27fe5942be5380d15e9a1ec866abe044a9ad635778ba61fc0776dc832b39451bd5d35072d2269cf9b040a2a2fba158a0d8085926dc2e44f0c88bf487da56e13ef2d5e676a8589881b4869ed4c7f0218ff8c6c7dd7221d189c65b3b9aaa71a01484b122846c7c7b57e02e679ea8469b70e14fe4f70fee4d87b910cf144be6fe48eef24da475c0b0bcc6565a9f99728426ce2380a9580e2a9442481ceae7679906c30b1a0e21a10f26150e0645ab6edfdab1ce8f8bea7b1dee511c5fd38ac0e702c1c15bb86b52bca1b71e15b96982d262a442024c33ceb7dd8f949063c2e5e613e873250e2f8708bd4e1924abd45f65c2fa5617bfb10ee9e4a42d6b5811acc8029c16274f937dac9e8817c7e579fdb767ffe277f26d413ced06b620ede8362081da21cf67c2ca9d6f15fe5bc05f82f5bb93f8916bad3d63338ca824f3bbc11b57ce94a5fa1bc239533679903d6fec92a8c792fd86e2960188c14f21e399cfd72a50c620e10aefc6249360b463df9a89bf6836f4f26359207b765578e5ed76ae9f31b1cc48324be576e3d8e44d217445dba466f9b6293fdf05448584eb64f61e02903f834518622b7d4732471c6e0e22e22d1f45e31f0509eab39cdea5980a492a1da2aaac55a98a01216cd4bfe7abaa682af0fbff2dfed030ba28f1285df750e4d3477190dd193f8643b61d8ac1c427d590badb1f61a05d480908fbdc7c6f0502dd0c4abb51d725e92f95da2a8facb79881a844e2026911adcc659d1fb20a2fce63787c8bb0d9f6789c4b231c76da81c3f0718eb7156565a081d2be6b4170c0e0bcebddd459f53db2590c974bca0d705c055dee8c629bf854a5d58edc85228499ec6dde80cce4c8910b81b1e9e8b0f43bd39c8d69c3a80672729b7dc952dd9448688b6bd06afc2d2819cda80b66c57b52ccf7ac1a86601410d18d0c732f69de792e0894a9541684ef174de766fd4ce55efea8f53812867be6a391ac865802dbc26d93959df327ec2667c7256aa5a1d3c45a69a6158f285d6c97c3b8eedb09527848500517995a9eae4cd911df531544c77f5a9a2f22313e3eb72ca7a07dba243476bc926992e0d1e58b4a2fc8c7b01e0cad726237933ea319bad7537d39f3ed635d1e6c1d29e97b3d2160a09e30ee2b65ac5bce00996a73c008bcf351cecb97b6833b6d121dcf4644260b2946ea204732ac9954b228f0beaa15071930fd9583dfc466d12b5f0eeeba6dcf23d5ce8ae62ee5796359d97a4a15955c778d868d0ef9991d9f2833b5bb66119c5f8b396fd108baed7906cbb3cc376d13551caed97fece6f42a4c908ee279f1127fda1dd3ee77d8de0a6f3c135fa3f1cffe38591b6738dc97b55f0acc52be9753ce53e64d7e497bb00ca6123758df3b68fad99e35c04389f7514a8e36039f541598a417275e77869989782325a15b5342ac5011ff07af698584b476b35d941a4981eac590a07a092bb50342da5d3341f901aa07964a8d02b623c7b106dd0ae50bfa007a22d46c8772fa55558176602946cb1d11ea5460db7586fb89c6d3bcd3ab6dd20df4a4db63d2e7d52380800ad812b8640887e027e946df96488b47fbc4a4fadaa8beda4abe446fafea5403fae2ef", "decode": [ "4141414141414141414141414141414141414141414141414141414141414141", "4242424242424242424242424242424242424242424242424242424242424242", From 7c1edeb063086b75696e55035b5cba1731642141 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 21 Jan 2020 17:42:07 +0100 Subject: [PATCH 028/103] bolt04: minor JSON fix and generate the exact number of bytes for the padding --- 04-onion-routing.md | 4 ++-- bolt04/onion-test-v0.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index 9fdf357cb..8d0f343a8 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -509,11 +509,11 @@ The construction returns a single 1366-byte packet along with the first receivin The packet construction is performed in the reverse order of the route, i.e. the last hop's operations are applied first. -The packet is initialized with 1366 _random_ bytes derived from a CSPRNG +The packet is initialized with 1300 _random_ bytes derived from a CSPRNG (ChaCha20). The _pad_ key referenced above is used to extract additional random bytes from a ChaCha20 stream, using it as a CSPRNG for this purpose. Once the `paddingKey` has been obtained, ChaCha20 is used with an all zero nonce, to -generate 1366 random bytes. Those random bytes are then used as the starting +generate 1300 random bytes. Those random bytes are then used as the starting state of the mix-header to be created. A filler is generated (see [Filler Generation](#filler-generation)) using the diff --git a/bolt04/onion-test-v0.json b/bolt04/onion-test-v0.json index bf59320aa..66755f4fe 100644 --- a/bolt04/onion-test-v0.json +++ b/bolt04/onion-test-v0.json @@ -47,7 +47,7 @@ "payload": "0404040404040404000000000000000400000004000000000000000000000000", "rhokey": "034e18b8cc718e8af6339106e706c52d8df89e2b1f7e9142d996acf88df8799b", "mukey": "8e45e5c61c2b24cb6382444db6698727afb063adecd72aada233d4bf273d975a", - "hmac": "16d4553c6084b369073d259381bb5b02c16bb2c590bbd9e69346cf7ebd563229 + "hmac": "16d4553c6084b369073d259381bb5b02c16bb2c590bbd9e69346cf7ebd563229" } ] }, From 75f46ba89bdaf95029db8d924ce426ef8bcf714a Mon Sep 17 00:00:00 2001 From: kiminuo <58662979+kiminuo@users.noreply.github.com> Date: Wed, 29 Jan 2020 10:11:46 +0100 Subject: [PATCH 029/103] Update 01-messaging.md (#732) Add missing parenthesis in link. --- 01-messaging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-messaging.md b/01-messaging.md index 4b9a7e0da..40d1909d0 100644 --- a/01-messaging.md +++ b/01-messaging.md @@ -222,7 +222,7 @@ integers can be omitted: The following convenience types are also defined: * `chain_hash`: a 32-byte chain identifier (see [BOLT #0](00-introduction.md#glossary-and-terminology-guide)) -* `channel_id`: a 32-byte channel_id (see [BOLT #2](02-peer-protocol.md#definition-of-channel-id) +* `channel_id`: a 32-byte channel_id (see [BOLT #2](02-peer-protocol.md#definition-of-channel-id)) * `sha256`: a 32-byte SHA2-256 hash * `signature`: a 64-byte bitcoin Elliptic Curve signature * `point`: a 33-byte Elliptic Curve point (compressed encoding as per [SEC 1 standard](http://www.secg.org/sec1-v2.pdf#subsubsection.2.3.3)) From 0bb69d3a378a9149b955f3388cbda39ecd1359db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorkil=20V=C3=A6rge?= Date: Fri, 31 Jan 2020 09:23:15 +0100 Subject: [PATCH 030/103] Fix bad wording of amount requirement in Bolt11 (#733) --- 11-payment-encoding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/11-payment-encoding.md b/11-payment-encoding.md index f10bb7b4c..2103e4a01 100644 --- a/11-payment-encoding.md +++ b/11-payment-encoding.md @@ -64,7 +64,7 @@ A writer: - if a specific minimum `amount` is required for successful payment: - MUST include that `amount`. - MUST encode `amount` as a positive decimal integer with no leading 0s. - - If the `p` multiplier is used the `amount` the last decimal MUST be `0`. + - If the `p` multiplier is used the last decimal of `amount` MUST be `0`. - SHOULD use the shortest representation possible, by using the largest multiplier or omitting the multiplier. From 458b0d34e1f2156da45067911c6774bad65f6a12 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 14 Oct 2019 13:59:23 +1030 Subject: [PATCH 031/103] BOLT 7: be more aggressive about sending our own gossip. As more nodes on the network use timestamp_filter to block gossip floods, we've seen some propagation problems. This should avoid it (and is implemented now by c-lightning). Signed-off-by: Rusty Russell --- 07-routing-gossip.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/07-routing-gossip.md b/07-routing-gossip.md index 6ae579d8a..ec1a8f016 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -828,9 +828,11 @@ The receiver: equal to `first_timestamp`, and less than `first_timestamp` plus `timestamp_range`. - MAY wait for the next outgoing gossip flush to send these. - - SHOULD restrict future gossip messages to those whose `timestamp` - is greater or equal to `first_timestamp`, and less than - `first_timestamp` plus `timestamp_range`. + - SHOULD send gossip messages as it generates them regardless of `timestamp`. + - Otherwise (relayed gossip): + - SHOULD restrict future gossip messages to those whose `timestamp` + is greater or equal to `first_timestamp`, and less than + `first_timestamp` plus `timestamp_range`. - If a `channel_announcement` has no corresponding `channel_update`s: - MUST NOT send the `channel_announcement`. - Otherwise: @@ -855,6 +857,12 @@ is simple to implement. In the case where the `channel_announcement` is nonetheless missed, `query_short_channel_ids` can be used to retrieve it. +Nodes can use `timestamp_filter` to reduce their gossip load when they +have many peers (eg. setting `first_timestamp` to `0xFFFFFFFF` after the +first few peers, in the assumption that propagation is adequate). +This assumption of adequate propagation does not apply for gossip messages +generated directly by the node itself, so they should ignore filters. + ## Initial Sync If a node requires an initial sync of gossip messages, it will be flagged @@ -872,7 +880,7 @@ interactions with them. A node: - if the `gossip_queries` feature is negotiated: - - MUST NOT relay any gossip messages unless explicitly requested. + - MUST NOT relay any gossip messages it did not generate itself, unless explicitly requested. - otherwise: - if it requires a full copy of the peer's routing state: - SHOULD set the `initial_routing_sync` flag to 1. @@ -904,7 +912,7 @@ A receiving node: A node: - if the `gossip_queries` feature is negotiated: - - MUST not send gossip until it receives `gossip_timestamp_filter`. + - MUST not send gossip it did not generate itself, until it receives `gossip_timestamp_filter`. - SHOULD flush outgoing gossip messages once every 60 seconds, independently of the arrival times of the messages. - Note: this results in staggered announcements that are unique (not From 2afe097f68399902011180ec239ec9e1466f7693 Mon Sep 17 00:00:00 2001 From: Jan Xie Date: Fri, 14 Feb 2020 16:45:32 +0800 Subject: [PATCH 032/103] Fix a typo in `insert_secret` pseudo code (#741) ... to make it consistent with the `where_to_put_secret` above. --- 03-transactions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/03-transactions.md b/03-transactions.md index c72bd0981..fc5e53ad5 100644 --- a/03-transactions.md +++ b/03-transactions.md @@ -575,7 +575,7 @@ A double-check, that all previous secrets derive correctly, is needed; if this check fails, the secrets were not generated from the same seed: insert_secret(secret, I): - B = where_to_put_secret(secret, I) + B = where_to_put_secret(I) # This tracks the index of the secret in each bucket across the traversal. for b in 0 to B: From fb7102e034c436954e33635a7ce8523e03370ad7 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Mon, 17 Feb 2020 11:00:30 +0100 Subject: [PATCH 033/103] Remove reference to DER encoding for public keys in compressed format (#742) ECDSA signatures in Bitcoin are DER-encoded but public keys are not. The compressed format for public keys is for example standardized in Sections 2.3.3 and 2.3.4 of Standards for Efficient Cryptography, SEC 1: Elliptic Curve Cryptography, Certicom Research, Version 2, 2009, https://www.secg.org/sec1-v2.pdf --- 02-peer-protocol.md | 4 ++-- 03-transactions.md | 2 +- 04-onion-routing.md | 2 +- 08-transport.md | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/02-peer-protocol.md b/02-peer-protocol.md index 1f4f0a5ee..1c2b06cb4 100644 --- a/02-peer-protocol.md +++ b/02-peer-protocol.md @@ -194,7 +194,7 @@ The sending node: - MUST ensure `temporary_channel_id` is unique from any other channel ID with the same peer. - MUST set `funding_satoshis` to less than 2^24 satoshi. - MUST set `push_msat` to equal or less than 1000 * `funding_satoshis`. - - MUST set `funding_pubkey`, `revocation_basepoint`, `htlc_basepoint`, `payment_basepoint`, and `delayed_payment_basepoint` to valid DER-encoded, compressed, secp256k1 pubkeys. + - MUST set `funding_pubkey`, `revocation_basepoint`, `htlc_basepoint`, `payment_basepoint`, and `delayed_payment_basepoint` to valid secp256k1 pubkeys in compressed format. - MUST set `first_per_commitment_point` to the per-commitment point to be used for the initial commitment transaction, derived as specified in [BOLT #3](03-transactions.md#per-commitment-secret-requirements). - MUST set `channel_reserve_satoshis` greater than or equal to `dust_limit_satoshis`. - MUST set undefined bits in `channel_flags` to 0. @@ -232,7 +232,7 @@ The receiving node MUST fail the channel if: - `max_accepted_htlcs` is greater than 483. - it considers `feerate_per_kw` too small for timely processing or unreasonably large. - `funding_pubkey`, `revocation_basepoint`, `htlc_basepoint`, `payment_basepoint`, or `delayed_payment_basepoint` -are not valid DER-encoded compressed secp256k1 pubkeys. +are not valid secp256k1 pubkeys in compressed format. - `dust_limit_satoshis` is greater than `channel_reserve_satoshis`. - the funder's amount for the initial commitment transaction is not sufficient for full [fee payment](03-transactions.md#fee-payment). - both `to_local` and `to_remote` amounts for the initial commitment transaction are less than or equal to `channel_reserve_satoshis` (see [BOLT 3](03-transactions.md#commitment-transaction-outputs)). diff --git a/03-transactions.md b/03-transactions.md index fc5e53ad5..49a47b1bc 100644 --- a/03-transactions.md +++ b/03-transactions.md @@ -62,7 +62,7 @@ Most transaction outputs used here are pay-to-witness-script-hash[BIP141](h `2 2 OP_CHECKMULTISIG` -* Where `pubkey1` is the numerically lesser of the two DER-encoded `funding_pubkey` and where `pubkey2` is the numerically greater of the two. +* Where `pubkey1` is the numerically lesser of the two `funding_pubkey` in compressed format, and where `pubkey2` is the numerically greater of the two. ## Commitment Transaction diff --git a/04-onion-routing.md b/04-onion-routing.md index 8d0f343a8..eb10b4905 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -441,7 +441,7 @@ simply discard its payload. The origin node establishes a shared secret with each hop along the route using Elliptic-curve Diffie-Hellman between the sender's ephemeral key at that hop and the hop's node ID key. The resulting curve point is serialized to the -DER-compressed representation and hashed using `SHA256`. The hash output is used +compressed format and hashed using `SHA256`. The hash output is used as the 32-byte shared secret. Elliptic-curve Diffie-Hellman (ECDH) is an operation on an EC private key and diff --git a/08-transport.md b/08-transport.md index 699b02b0f..391b01ba4 100644 --- a/08-transport.md +++ b/08-transport.md @@ -154,7 +154,7 @@ The following functions will also be referenced: * `ECDH(k, rk)`: performs an Elliptic-Curve Diffie-Hellman operation using `k`, which is a valid `secp256k1` private key, and `rk`, which is a valid public key - * The returned value is the SHA256 of the DER-compressed format of the + * The returned value is the SHA256 of the compressed format of the generated point. * `HKDF(salt,ikm)`: a function defined in `RFC 5869`[3](#reference-3), @@ -202,11 +202,11 @@ As a concluding step, both sides mix the responder's public key into the handshake digest: * The initiating node mixes in the responding node's static public key - serialized in Bitcoin's DER-compressed format: + serialized in Bitcoin's compressed format: * `h = SHA-256(h || rs.pub.serializeCompressed())` * The responding node mixes in their local static public key serialized in - Bitcoin's DER-compressed format: + Bitcoin's compressed format: * `h = SHA-256(h || ls.pub.serializeCompressed())` ### Handshake Exchange From 38479359a1577ea656ad1e5035f64d2157a5d256 Mon Sep 17 00:00:00 2001 From: araspitzu Date: Tue, 18 Feb 2020 09:21:22 +0100 Subject: [PATCH 034/103] Single-option large channel proposal (#596) Add option to open large channels (wumbo). --- 02-peer-protocol.md | 15 +++++++++++---- 09-features.md | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/02-peer-protocol.md b/02-peer-protocol.md index 1c2b06cb4..66d539e5e 100644 --- a/02-peer-protocol.md +++ b/02-peer-protocol.md @@ -187,12 +187,20 @@ The `shutdown_scriptpubkey` allows the sending node to commit to where funds will go on mutual close, which the remote node should enforce even if a node is compromised later. +The `option_support_large_channel` is a feature used to let everyone +know this node will accept `funding_satoshis` greater than or equal to 2^24. +Since it's broadcast in the `node_announcement` message other nodes can use it to identify peers +willing to accept large channel even before exchanging the `init` message with them. + #### Requirements The sending node: - MUST ensure the `chain_hash` value identifies the chain it wishes to open the channel within. - MUST ensure `temporary_channel_id` is unique from any other channel ID with the same peer. - - MUST set `funding_satoshis` to less than 2^24 satoshi. + - if both nodes advertised `option_support_large_channel`: + - MAY set `funding_satoshis` greater than or equal to 2^24 satoshi. + - otherwise: + - MUST set `funding_satoshis` to less than 2^24 satoshi. - MUST set `push_msat` to equal or less than 1000 * `funding_satoshis`. - MUST set `funding_pubkey`, `revocation_basepoint`, `htlc_basepoint`, `payment_basepoint`, and `delayed_payment_basepoint` to valid secp256k1 pubkeys in compressed format. - MUST set `first_per_commitment_point` to the per-commitment point to be used for the initial commitment transaction, derived as specified in [BOLT #3](03-transactions.md#per-commitment-secret-requirements). @@ -236,15 +244,14 @@ are not valid secp256k1 pubkeys in compressed format. - `dust_limit_satoshis` is greater than `channel_reserve_satoshis`. - the funder's amount for the initial commitment transaction is not sufficient for full [fee payment](03-transactions.md#fee-payment). - both `to_local` and `to_remote` amounts for the initial commitment transaction are less than or equal to `channel_reserve_satoshis` (see [BOLT 3](03-transactions.md#commitment-transaction-outputs)). + - `funding_satoshis` is greater than or equal to 2^24 and the receiver does not support `option_support_large_channel`. The receiving node MUST NOT: - consider funds received, using `push_msat`, to be received until the funding transaction has reached sufficient depth. #### Rationale -The requirement for `funding_satoshi` to be less than 2^24 satoshi is a temporary self-imposed limit while implementations are not yet considered stable. -It can be lifted at any point in time, or adjusted for other currencies, since it is solely enforced by the endpoints of a channel. -Specifically, [the routing gossip protocol](07-routing-gossip.md) does not discard channels that have a larger capacity. +The requirement for `funding_satoshis` to be less than 2^24 satoshi was a temporary self-imposed limit while implementations were not yet considered stable, it can be lifted by advertising `option_support_large_channel`. The *channel reserve* is specified by the peer's `channel_reserve_satoshis`: 1% of the channel total is suggested. Each side of a channel maintains this reserve so it always has something to lose if it were to try to broadcast an old, revoked commitment transaction. Initially, this reserve may not be met, as only one side has funds; but the protocol ensures that there is always progress toward meeting this reserve, and once met, it is maintained. diff --git a/09-features.md b/09-features.md index 74e1c7925..d8a01ca4b 100644 --- a/09-features.md +++ b/09-features.md @@ -37,6 +37,7 @@ The Context column decodes as follows: | 12/13 | `option_static_remotekey` | Static key for remote output | IN | | [BOLT #3](03-transactions.md) | | 14/15 | `payment_secret` | Node supports `payment_secret` field | IN9 | `var_onion_optin` | [Routing Onion Specification][bolt04] | | 16/17 | `basic_mpp` | Node can receive basic multi-part payments | IN9 | `payment_secret` | [BOLT #4][bolt04-mpp] | +| 18/19 | `option_support_large_channel` | Can create large channels | INC+ | | [BOLT #2](02-peer-protocol.md#the-open_channel-message) | ## Requirements From 7b0169263eb6471c42fb557a0bdfae7473efb25d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 18 Feb 2020 19:16:58 +1030 Subject: [PATCH 035/103] BOLT 1: add networks to init message. (#682) Add networks to init message via TLV extension. This prevents accidentally connecting a testnet node to mainnet or the other way around. --- 01-messaging.md | 17 +++++++++++++++++ 07-routing-gossip.md | 2 ++ 2 files changed, 19 insertions(+) diff --git a/01-messaging.md b/01-messaging.md index 40d1909d0..ef4768220 100644 --- a/01-messaging.md +++ b/01-messaging.md @@ -244,8 +244,17 @@ The `features` field MUST be padded to bytes with 0s. * [`gflen*byte`:`globalfeatures`] * [`u16`:`flen`] * [`flen*byte`:`features`] + * [`init_tlvs`:`tlvs`] + +1. tlvs: `init_tlvs` +2. types: + 1. type: 1 (`networks`) + 2. data: + * [`...*chain_hash`:`chains`] +The optional `networks` indicates the chains the node is interested in. + #### Requirements The sending node: @@ -254,6 +263,7 @@ The sending node: - MUST set any undefined feature bits to 0. - SHOULD NOT set features greater than 13 in `globalfeatures`. - SHOULD use the minimum length required to represent the `features` field. + - SHOULD set `networks` to all chains it will gossip or open channels for. The receiving node: - MUST wait to receive `init` before sending any other messages. @@ -263,6 +273,8 @@ The receiving node: - MUST ignore the bit. - upon receiving unknown _even_ feature bits that are non-zero: - MUST fail the connection. + - upon receiving `networks` containing no common chains + - MAY fail the connection. - if the feature vector does not set all known, transitive dependencies: - MUST fail the connection. @@ -276,6 +288,11 @@ This semantic allows both future incompatible changes and future backward compat Nodes wait for receipt of the other's features to simplify error diagnosis when features are incompatible. +Since all networks share the same port, but most implementations only +support a single network, the `networks` fields avoids nodes +erroneously believing they will receive updates about their preferred +network, or that they can open channels. + ### The `error` Message For simplicity of diagnosis, it's often useful to tell a peer that something is incorrect. diff --git a/07-routing-gossip.md b/07-routing-gossip.md index ec1a8f016..010851d98 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -917,6 +917,8 @@ A node: the arrival times of the messages. - Note: this results in staggered announcements that are unique (not duplicated). + - SHOULD NOT forward gossip messages to peers who sent `networks` in `init` + and did not specify the `chain_hash` of this gossip message. - MAY re-announce its channels regularly. - Note: this is discouraged, in order to keep the resource requirements low. - upon connection establishment: From a2afdfd12b84a9e62131b3220da51872fe7ba5dd Mon Sep 17 00:00:00 2001 From: Orfeas Stefanos Thyfronitis Litos <18602747+OrfeasLitos@users.noreply.github.com> Date: Tue, 18 Feb 2020 08:51:57 +0000 Subject: [PATCH 036/103] Keep `hmac` case consistent (#547) Use `hmac` (lower-case) in packet fields to stay consistent with other fields. --- 04-onion-routing.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/04-onion-routing.md b/04-onion-routing.md index eb10b4905..5bdf88d2b 100644 --- a/04-onion-routing.md +++ b/04-onion-routing.md @@ -140,7 +140,7 @@ The packet consists of four sections: generation - a 1300-byte `hop_payloads` consisting of multiple, variable length, `hop_payload` payloads or up to 20 fixed sized legacy `hop_data` payloads. - - a 32-byte `HMAC`, used to verify the packet's integrity + - a 32-byte `hmac`, used to verify the packet's integrity The network format of the packet consists of the individual sections serialized into one contiguous byte-stream and then transferred to the packet @@ -165,11 +165,11 @@ It is 1300 bytes long and has the following structure: 2. data: * [`varint`:`length`] * [`hop_payload_length`:`hop_payload`] - * [`32*byte`:`HMAC`] + * [`32*byte`:`hmac`] * ... * `filler` -Where, the `length`, `hop_payload` (with contents dependent on `length`), and `HMAC` are repeated for each hop; +Where, the `length`, `hop_payload` (with contents dependent on `length`), and `hmac` are repeated for each hop; and where, `filler` consists of obfuscated, deterministically-generated padding, as detailed in [Filler Generation](#filler-generation). Additionally, `hop_payloads` is incrementally obfuscated at each hop. @@ -526,7 +526,7 @@ following operations: - `shift_size` is defined as the length of the `hop_payload` plus the varint encoding of the length and the length of that HMAC. Thus if the payload length is `l` then the `shift_size` is `1 + l + 32` for `l < 253`, otherwise `3 + l + 32` due to the varint encoding of `l`. - The `hop_payload` field is right-shifted by `shift_size` bytes, discarding the last `shift_size` bytes that exceed its 1300-byte size. - - The varint-serialized length, serialized `hop_payload` and `HMAC` are copied into the following `shift_size` bytes. + - The varint-serialized length, serialized `hop_payload` and `hmac` are copied into the following `shift_size` bytes. - The _rho_-key is used to generate 1300 bytes of pseudo-random byte stream which is then applied, with `XOR`, to the `hop_payloads` field. - If this is the last hop, i.e. the first iteration, then the tail of the @@ -665,7 +665,7 @@ generates `2*1300` pseudo-random bytes (using the _rho_-key), and applies the re The first few bytes correspond to the varint-encoded length `l` of the `hop_payload`, followed by `l` bytes of the resulting routing information become the `hop_payload`, and the 32 byte HMAC. The next 1300 bytes are the `hop_payloads` for the outgoing packet. -A special `HMAC` value of 32 `0x00`-bytes indicates that the currently processing hop is the intended recipient and that the packet should not be forwarded. +A special `hmac` value of 32 `0x00`-bytes indicates that the currently processing hop is the intended recipient and that the packet should not be forwarded. If the HMAC does not indicate route termination, and if the next hop is a peer of the processing node; then the new packet is assembled. Packet assembly is accomplished From dcbf8583976df087c79c3ce0b535311212e6812d Mon Sep 17 00:00:00 2001 From: Bastien Teinturier <31281497+t-bast@users.noreply.github.com> Date: Tue, 18 Feb 2020 09:53:12 +0100 Subject: [PATCH 037/103] Clarify numerical comparison of pubkeys (#743) We are using lexixographic order (which is the same as big-endian when inputs have the same size, such as compressed public keys). --- .aspell.en.pws | 1 + 03-transactions.md | 2 +- 07-routing-gossip.md | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.aspell.en.pws b/.aspell.en.pws index 15b8def16..e897f76bb 100644 --- a/.aspell.en.pws +++ b/.aspell.en.pws @@ -375,3 +375,4 @@ GitHub IRC bitmasks CSPRNG +lexicographically diff --git a/03-transactions.md b/03-transactions.md index 49a47b1bc..d01bee93b 100644 --- a/03-transactions.md +++ b/03-transactions.md @@ -62,7 +62,7 @@ Most transaction outputs used here are pay-to-witness-script-hash[BIP141](h `2 2 OP_CHECKMULTISIG` -* Where `pubkey1` is the numerically lesser of the two `funding_pubkey` in compressed format, and where `pubkey2` is the numerically greater of the two. +* Where `pubkey1` is the lexicographically lesser of the two `funding_pubkey` in compressed format, and where `pubkey2` is the lexicographically greater of the two. ## Commitment Transaction diff --git a/07-routing-gossip.md b/07-routing-gossip.md index 010851d98..54b685d47 100644 --- a/07-routing-gossip.md +++ b/07-routing-gossip.md @@ -166,8 +166,8 @@ The origin node: as specified in [BOLT #2](02-peer-protocol.md#the-funding_locked-message). - Note: the corresponding output MUST be a P2WSH, as described in [BOLT #3](03-transactions.md#funding-transaction-output). - MUST set `node_id_1` and `node_id_2` to the public keys of the two nodes - operating the channel, such that `node_id_1` is the numerically-lesser of the - two DER-encoded keys sorted in ascending numerical order. + operating the channel, such that `node_id_1` is the lexicographically-lesser of the + two compressed keys sorted in ascending lexicographic order. - MUST set `bitcoin_key_1` and `bitcoin_key_2` to `node_id_1` and `node_id_2`'s respective `funding_pubkey`s. - MUST compute the double-SHA256 hash `h` of the message, beginning at offset From eccb27b4a8f9deaa87372656317d9e603b281477 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 19:43:27 +0930 Subject: [PATCH 038/103] tests: spec for test vectors, and a simple example. I initially used JSON, but it was not human-writable. The simple DSL is much more human-writable, and readable. Signed-off-by: Rusty Russell --- tests/events/README.md | 23 + tests/events/bolt1-01-init.events | 61 ++ tests/events/test-spec.md | 203 +++++ tools/Makefile | 6 + tools/test-events.py | 1340 +++++++++++++++++++++++++++++ 5 files changed, 1633 insertions(+) create mode 100644 tests/events/README.md create mode 100644 tests/events/bolt1-01-init.events create mode 100644 tests/events/test-spec.md create mode 100644 tools/Makefile create mode 100755 tools/test-events.py diff --git a/tests/events/README.md b/tests/events/README.md new file mode 100644 index 000000000..470ea8679 --- /dev/null +++ b/tests/events/README.md @@ -0,0 +1,23 @@ +# Implementation Tests for Lightning Specifications + +This directory contains conversation-style tests for Lightning +implementations. The format is documented in +[tests/events/test-spec.md](events/test-spec.md), and the base driver for an +implementation is in the [tools/test-events.py](../tools/test-events.py). + +To run the tests, you need to write a driver for your particular +implementation, like the one for +[c-lightning](../tools/test-events-clightning.py). Then extract the +format of all messages into a file, like so: + + $ python3 tools/extract-formats.py 0*.md > format.csv + +Finally, you can run a test like so: + + $ tools/test-events-clightning.py formats.csv tests/events/*.events + +The `-v` option will give more verbose output, which is particularly +useful when debugging your test script. + +Good luck! +Rusty. diff --git a/tests/events/bolt1-01-init.events b/tests/events/bolt1-01-init.events new file mode 100644 index 000000000..4eea9e6b7 --- /dev/null +++ b/tests/events/bolt1-01-init.events @@ -0,0 +1,61 @@ +# Variations on init exchange. +# Spec: MUST respond to known feature bits as specified in [BOLT #9](09-features.md). + +# Trivial variable to serve as a demonstration +EXPECT_INIT=expect-send: type=init + +1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 +2. $EXPECT_INIT conn=0000000000000000000000000000000000000000000000000000000000000003 +3. recv: type=init globalfeatures= localfeatures= + + 1. nothing + 1. disconnect: + +4. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + # Even if we don't send anything, it should send init. + 1. $EXPECT_INIT + + # Minimal possible init message. + # Spec: MUST send `init` as the first Lightning message for any connection. + 1. $EXPECT_INIT + 2. recv: type=init globalfeatures= localfeatures= + + # Sanity check that bits 14 and 15 are not used! + 1. $EXPECT_INIT globalfeatures=0000/C000 + # init msg with unknown odd global bit (15): no error + 2. recv: type=init globalfeatures=8000 localfeatures= + + 1. $EXPECT_INIT localfeatures=0000/C000 + # init msg with unknown odd local bit (15): no error + 2. recv: type=init globalfeatures= localfeatures=8000 + + # init msg with unknown even global bit (14): you will error + 1. $EXPECT_INIT + 2. recv: type=init globalfeatures=4000 localfeatures= + 3. expect-error: + + # init msg with unknown even local bit (14): you will error + 1. $EXPECT_INIT + 2. recv: type=init globalfeatures= localfeatures=4000 + 3. expect-error: + + # If you don't support `option_data_loss_protect`, you will be ok if + # we ask for it. + 1. $EXPECT_INIT localfeatures=00/03 !option_data_loss_protect + 2. recv: type=init globalfeatures= localfeatures=02 !option_data_loss_protect + + # If you don't support `option_data_loss_protect`, you will error if + # we require it. + 1. $EXPECT_INIT localfeatures=00/03 !option_data_loss_protect + 2. recv: type=init globalfeatures= localfeatures=01 !option_data_loss_protect + 3. expect-error: !option_data_loss_protect + + # If you support `option_data_loss_protect`, you will advertize it odd. + 1. $EXPECT_INIT localfeatures=02/03 option_data_loss_protect/odd + + # If you require `option_data_loss_protect`, you will advertize it even. + 1. $EXPECT_INIT localfeatures=01/03 option_data_loss_protect/even + + # Note: it's undefined what you'll do if implementation requires + # an option and isn't offered it. The recipient of the required feature + # bit should notice the requirement and error. diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md new file mode 100644 index 000000000..7ffcc41c4 --- /dev/null +++ b/tests/events/test-spec.md @@ -0,0 +1,203 @@ +# Format for Event-based Test Specifications. + +The programmatic test cases for the spec are a tree of events and +expected responses which test various scenarios described in the +specification. They serve only as guidelines: in some cases a +compliant implementation might produce a different response than that +given here, though that suggests further examination of the testcase, +the implementation, or both. + +## General Line Format + +FILE := SEQUENCE* + +SEQUENCE := SEQUENCE_LINE+ +SEQUENCE_LINE := SEQUENCE_STEP OPTION_SPEC* | META_LINE +SEQUENCE_STEP := INDENT4* NUMBER `.` SPACE+ EVENT_OR_ONEOF OPTION_SPEC* + +EVENT_OR_ONEOF := EVENT | `One of:` +EVENT := INPUT_EVENT | OUTPUT_EVENT | `nothing` + +META_LINE := COMMENT | SPACE* | VARSET | INCLUDE + +COMMENT := `#` [SPACE|STRING]* +VARSET := IDENTIFIER`=`[SPACE|STRING]* OPTION_SPEC* +INCLUDE := `include` SPACE STRING OPTION_SPEC* + +Comment and blank lines are ignored. + +Variable lines set variables which can be expanded in any position with +a `$` prefix. There's currently no scope to variables. + +Include lines pull in other files, which is helpful for complex tests. + +Other lines are indented by multiples of 4 spaces; a line not indented +by a multiple of 4 is be joined to the previous line (this allows +nicer formatting for long lines). + +Each non-comment line indicates something to do to the implementation +(input event) or some response it should give (output event). + +Indentation indicates alternative sequences, eg. this reflects two tests, +STEP1->STEP2a->STEP3 and STEP1->STEP2b->STEP3: + + 1. STEP1 + 1. STEP2a + 1. STEP2b + 2. STEP3 + +An step must either have NUMBER 1, in which case it follows directly +from the parent, or NUMBER one greater than the previous step at the +same level, in which case it follows the previous. + +There must be exactly one top-level `1.` step. + +The special marker 'One of:' indicate sequences starting with distinct +output events which could occur in any order. This is common for +gossip output which may be in various orders: + + 1. STEP1 + 2. One of: + 1. STEP2a + 2. STEP2b + 1. STEP2c + 2. STEP3 + +This means the test will accept STEP1->STEP2a->STEP2b->STEP3, or +STEP1->STEP2c->STEP3. + +## Option specifiers + +OPTION_SPEC := SPACE+ [`!`]OPTION_NAME +OPTION_NAME := `opt`IDENTIFIER[`/`ODD_OR_EVEN] +ODD_OR_EVEN := `odd` | `even` + +Some individual lines only apply if certain options are (not) supported. +If the implementation does not support the option (or does support the +option and it's preceeded by `!`), the line should be ignored. This +can be used to set/omit certain fields according to certain options, +or even whole steps. + +You can also filter by whether options are optional (`odd`) or +compulsory (`even`). + +## Input Events + +INPUT_EVENT := CONNECT | RECV | BLOCK | DISCONNECT | OPENCMD + +CONNECT := `connect:` SPACE+ CONNECT_OPTS +CONNECT_OPTS := `privkey=` HEX64 + +RECV := `recv:` [CONNSPEC] SPACE+ `type=` TYPENAME RECV_FIELDSPEC* +TYPENAME := IDENTIFIER|NUMBER +RECV_FIELDSPEC := SPACE+ IDENTIFIER`=`FIELDVALUE +FIELDVALUE := HEX | NUMBER + +BLOCK := `block:` `height=`NUMBER SPACE+ `n`=NUMBER SPACE+ [TX*] +TX := `tx=`HEXSTRING + +DISCONNECT := `disconnect:` SPACE+ CONNSPEC + +FUNDCHANCMD := `fundchannel:` [CONNSPEC] SPACE+ `amount=`NUMBER SPACE+ `utxo=`HEX`/`NUMBER + +INVOICECMD := `invoice:` SPACE+ `amount=`NUMBER SPACE+ `preimage=`HEX64 + +CONNSPEC := SPACE+ `conn=`HEX64 + +Input events are: +* `connect`: a connection established with another peer. These examples + assume a successful cryptographic handshake. We provide the private key. +* `recv`: an incoming message. The `type` is one of the message types + defined in the spec or a raw number. The other fields, if any, define + the individual fields: each non-optional field will be specified. Integer + fields can be specified as decimal integers, all other fields are hexidecimal + (note: this is confusing, as bitcoin usually reversed txids, and we don't!) + Length fields are not specified, but derived from the length of the hexidecimal + field. The special (hex) field `extra` indicates additional data to be appended. The optional `conn` argument allows you to specify which `connect` + you're referring to. The default is the last one. +* `block`: a generated block at a given height. Any `tx` specified + are to be placed in the (first) block. If `n` is more than 1, it's a short + cut for generating additional blocks. +* `disconnect`: a connection closed by a peer. +* `fundchannel`: tell the implementation to initiate the opening of a channel of the given `amount` of satoshis with the specific peer identified by `conn` (default, last `connect`). The funding comes from a single `utxo`, as specified by txid and output number. +* `invoice`: tell the implementation to accept a payment of `amount` msatoshis, with payment_preimage `preimage`. + +## Output Events + +OUTPUT_EVENT := EXPECT_SEND | MAYBE_SEND | EXPECT_TX | EXPECT_ERROR + +EXPECT_SEND := `expect-send:` [CONNSPEC] SPACE+ `type=` TYPENAME SPACE+ SEND_FIELDSPEC* +SEND_FIELDSPEC := IDENTIFIER`=`SPECVALUE +SPECVALUE := FIELDVALUE | HEX`/`HEX | `absent` + +MAYBE_SEND := `maybe-send:` [CONNSPEC] SPACE+ `type=` TYPENAME SEND_FIELDSPEC* + +EXPECT_TX := `expect-tx:` SPACE+ `tx=`HEX + +EXPECT_ERROR := `expect-error:` [CONNSPEC] + +Output events are: +* `expect-send`: a message the implementation is expected to send. Any field specified must match exactly for the test to pass; the value`/`mask notation is used to compare bits against a mask; the field should be zero-padded for comparison if necessary. The special field value `absent` means the (presumably optional) field must not be present. +* `maybe-send`: a message the implementation may send, at any point from now on (until the next `disconnect`) +* `expect-tx`: a transaction the implementation is expected to broadcast. The transactions here assume deterministic signatures. +* `expect-error`: the implementation is expected to detect an error. This is generally a `expect-send` of `type=error` but it's legal for it to simply close the connection. If there's no `expect-error` event, the implementation is expected *not* to have an error. + + +## Test Node Setup + +The peer secret of the test node is assumed +`0000000000000000000000000000000000000000000000000000000000000001` +which makes its public key +`0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`. + +## Blockchain Setup + +The initial blockchain is a bitcoind `regtest` chain, which has the +following initial blocks: + + Block 0 (genesis): 0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f20020000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000 + Block 1: 0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f7b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d04283f5a1095dffff7f200100000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0200f2052a01000000160014751e76e8199196d454941c45d1b3a323f1433bd60000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000 + +The coinbase pays 50 BTC to the following key/address: + + privkey: 0000000000000000000000000000000000000000000000000000000000000001 + WIF: cMahea7zqjxrtgAbB7LSGbcQUr1uX1ojuat9jZodMN87JcbXMTcA + P2WPKH: bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080 + +A further 100 blocks are generated to allow the 50BTC output to be +spent, with block 102 containing the following transaction, to allow +funding of channels with whole UTXOs for easy testing: + + 020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 + +Here are the keys to spend funds, derived from BIP32 seed `0000000000000000000000000000000000000000000000000000000000000001`: + + pubkey 0/0/1: 02d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b + privkey 0/0/1: 76edf0c303b9e692da9cb491abedef46ca5b81d32f102eb4648461b239cb0f99 + WIF 0/0/1: cRZtHFwyrV3CS1Muc9k4sXQRDhqA1Usgi8r7NhdEXLgM5CUEZufg + P2WPKH 0/0/1: bcrt1qsdzqt93xsyewdjvagndw9523m27e52er5ca7hm + UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1 (0.01BTC) + + pubkey 0/0/2: 038f1573b4238a986470d250ce87c7a91257b6ba3baf2a0b14380c4e1e532c209d + privkey 0/0/2: bc2f48a76a6b8815940accaf01981d3b6347a68fbe844f81c50ecbadf27cd179 + WIF 0/0/2: cTtWRYC39drNzaANPzDrgoYsMgs5LkfE5USKH9Kr9ySpEEdjYt3E + P2WPKH 0/0/2: bcrt1qlkt93775wmf33uacykc49v2j4tayn0yj25msjn + UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/0 (0.02BTC) + + pubkey 0/0/3: 02ffef0c295cf7ca3a4ceb8208534e61edf44c606e7990287f389f1ea055a1231c + privkey 0/0/3: 16c5027616e940d1e72b4c172557b3b799a93c0582f924441174ea556aadd01c + WIF 0/0/3: cNLxnoJSQDRzXnGPr4ihhy2oQqRBTjdUAM23fHLHbZ2pBsNbqMwb + P2WPKH 0/0/3: bcrt1q2ng546gs0ylfxrvwx0fauzcvhuz655en4kwe2c + UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/3 (0.03BTC) + + pubkey 0/0/4: 026957e53b46df017bd6460681d068e1d23a7b027de398272d0b15f59b78d060a9 + privkey 0/0/4: 53ac43309b75d9b86bef32c5bbc99c500910b64f9ae089667c870c2cc69e17a4 + WIF 0/0/4: cQPMJRjxse9i1jDeCo8H3khUMHYfXYomKbwF5zUqdPrFT6AmtTbd + P2WPKH 0/0/4: bcrt1qrdpwrlrmrnvn535l5eldt64lxm8r2nwkv0ruxq + UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/4 (0.04BTC) + + pubkey 0/0/5: 03a9f795ff2e4c27091f40e8f8277301824d1c3dfa6b0204aa92347314e41b1033 + privkey 0/0/5: 16be98a5d4156f6f3af99205e9bc1395397bca53db967e50427583c94271d27f + WIF 0/0/5: cNLuxyjvR6ga2q6fdmSKxAd1CPQDShKV9yoA7zFKT7GJwZXr9MmT + P2WPKH 0/0/5: bcrt1q622lwmdzxxterumd746eu3d3t40pq53p62zhlz + UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/2 (49.89995320BTC) diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 000000000..19c680565 --- /dev/null +++ b/tools/Makefile @@ -0,0 +1,6 @@ +#! /usr/bin/make + +check: + @# E501 line too long (N > 79 characters) + @# W503: line break before binary operator + flake8 --ignore=E501,W503 test-events.py diff --git a/tools/test-events.py b/tools/test-events.py new file mode 100755 index 000000000..893c1d34b --- /dev/null +++ b/tools/test-events.py @@ -0,0 +1,1340 @@ +#! /usr/bin/python3 +# This script exercises a lightning implementation using a JSON test case. + +# Released by Rusty Russell under CC0: +# https://creativecommons.org/publicdomain/zero/1.0/ + +import argparse +from copy import copy +import fileinput +import networkx as nx +from os import path +import re +import string +import struct +import sys +import matplotlib.pyplot as plt + +# Populated by read_csv +messages = [] + +# From 01-messaging.md#fundamental-types: +name2size = {'byte': 1, + 'u16': 2, + 'u32': 4, + 'u64': 8, + 'short_channel_id': 8, + 'chain_hash': 32, + 'channel_id': 32, + 'sha256': 32, + 'preimage': 32, + 'secret': 32, + 'point': 33, + 'pubkey': 33, + 'signature': 64} + +name2structfmt = {'byte': 'B', + 'u16': '>H', + 'u32': '>I', + 'u64': '>Q', + 'short_channel_id': '>Q'} + + +def setup_cmdline_options(): + """Create an argparse.ArgumentParser for standard cmdline options""" + class OptionAction(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + if not values.endswith('/even') and not values.endswith('/odd'): + raise argparse.ArgumentTypeError("{} must end in /odd or /even" + .format(option_string)) + super().__call__(parser, namespace, values, option_string) + + parser = argparse.ArgumentParser() + parser.add_argument('csv_file', help='CSV file describing packet formats)') + parser.add_argument('input', nargs='*', default=[None], + help='Files to read in (or stdin)') + parser.add_argument('-v', '--verbose', help='Show working', + action="store_true") + parser.add_argument('--draw-events', help='Output ".png"', + action="store_true") + parser.add_argument('--exhaustive', help='Try all possible paths', + action="store_true") + parser.add_argument('--via', type=str, + help='Test shortest path via this specific [file:]line') + parser.add_argument('--flatten-failpath', help='Output a valid input file for the failing path', + action="store_true") + parser.add_argument('-o', '--option', action=OptionAction, default=[], + help='Indicate supported option') + + return parser + + +class Line(object): + """Line of input from the testfile (could be multiple if they continue)""" + def __init__(self, filename, linestart, lineend, indentlevel, line): + self.filename = filename + self.linestart = linestart + self.lineend = lineend + self.indentlevel = indentlevel + self.line = line[:] + + def __copy__(self): + return Line(self.filename, self.linestart, self.lineend, + self.indentlevel, self.line) + + def __iadd__(self, other): + """+= two Lines: assumes they are adjacent.""" + if type(other) != Line: + return NotImplemented + # Tokens across filesystem boundaries (ie. include) don't add. + if other.filename == self.filename: + self.linestart = min(self.linestart, other.linestart) + self.lineend = max(self.lineend, other.lineend) + self.line += '\n' + other.line + return self + + def __str__(self): + # Human-readable line numbers are 1-based + if self.linestart == self.lineend: + return "{}:{}".format(self.filename, self.linestart + 1) + else: + return "{}:{}-{}".format(self.filename, self.linestart + 1, + self.lineend + 1) + + def __repr__(self): + return "Line " + self.__str__() + + def flatten(self, index, stopline, prefix): + print("{}# {}".format(prefix, self)) + parts = self.line.partition('.') + print("{}{}.{}".format(prefix, index, parts[2])) + return self == stopline, index + 1 + + +def pack(typename, v): + """Pack this value as this type""" + if typename in name2structfmt: + return struct.pack(name2structfmt[typename], v) + + # Pack directly as bytes + assert len(v) == name2size[typename] + return bytes(v) + + +def unpack_from(typename, bytestream, offset): + """Unpack from bytestream as this type. Returns len, value, or None, None""" + if typename in name2structfmt: + size = struct.calcsize(name2structfmt[typename]) + if size + offset > len(bytestream): + return None, None + return (struct.calcsize(name2structfmt[typename]), + struct.unpack_from(name2structfmt[typename], bytestream, + offset)[0]) + + # Unpack directly as bytes + size = name2size[typename] + if size + offset > len(bytestream): + return None, None + return size, bytestream[offset:offset + size] + + +class ValidationError(Exception): + def __init__(self, line, message): + self.line = line + # Call the base class constructor with the parameters it needs + super().__init__(str(line) + ": Validation failed: " + message) + + +class LineError(Exception): + def __init__(self, line, message): + # Call the base class constructor with the parameters it needs + super().__init__(str(line) + ": Parsing failed:" + message) + + +# #### Dummy runner which you should replace with real one. #### +class DummyRunner(object): + def __init__(self, args): + self.verbose = args.verbose + pass + + def restart(self): + if self.verbose: + print("[RESTART]") + self.blockheight = 102 + + def connect(self, id, line): + if self.verbose: + print("[CONNECT {}]".format(line)) + + def getblockheight(self): + return self.blockheight + + def trim_blocks(self, newheight): + if self.verbose: + print("[TRIMBLOCK TO HEIGHT {}]".format(newheight)) + self.blockheight = newheight + + def add_blocks(self, txs, n, line): + if self.verbose: + print("[ADDBLOCKS {} WITH {} TXS]".format(n, len(txs))) + self.blockheight += n + + def disconnect(self, conn, line): + if self.verbose: + print("[DISCONNECT {}]".format(line)) + + def recv(self, conn, outbuf, line): + if self.verbose: + print("[RECV {} {}]".format(line, outbuf.hex())) + + def fundchannel(self, conn, amount, txid, outnum, line): + if self.verbose: + print("[FUNDCHANNEL TO {} for {} with UTXO {}/{} {}]" + .format(conn, amount, txid, outnum, line)) + + def invoice(self, amount, preimage, line): + if self.verbose: + print("[INVOICE for {} with PREIMAGE {} {}]" + .format(amount, preimage, line)) + + def expect_send(self, conn, line): + if self.verbose: + print("[EXPECT-SEND {}]".format(line)) + # return bytes.fromhex(input("{}? ".format(line))) + + def expect_tx(self, tx, line): + if self.verbose: + print("[EXPECT-TX {} {}]".format(tx.hex(), line)) + + def expect_error(self, conn, line): + if self.verbose: + print("[EXPECT-ERROR {}]", line) + + def final_error(self): + if self.verbose: + print("[EXPECT NO ERROR]") + return None + +# #### End dummy runner which you should replace with real one. #### + + +class Field(object): + def __init__(self, message, name, typename, count, options): + self.message = message + self.name = name + self.typename = typename + self.options = options + self.islenvar = False + # This contains all the integer types: otherwise it's a hexstring + self.isinteger = typename in name2structfmt + + # This is set for static-sized array. + self.arraylen = None + # This is set for variable-sized array. + self.arrayvar = None + + if count: + # If array is a variable, must be prior field. + try: + self.arraylen = int(count) + except ValueError: + self.arrayvar = message.findField(count) + self.arrayvar.islenvar = True + + @staticmethod + def field_from_str(line, typename, isinteger, s): + if typename == "short_channel_id": + parts = s.split('x') + if len(parts) != 3: + raise LineError(line, "short_channel_id should be NxNxN") + try: + return ((int(parts[0]) << 40) + | (int(parts[1]) << 16) | (int(parts[2]))) + except ValueError: + raise LineError(line, "short_channel_id should be xx") + # Int variants + if isinteger: + try: + v = int(s) + except ValueError: + raise LineError(line, "{} should be integer".format(typename)) + + if v >= (1 << (name2size[typename] * 8)): + raise LineError(line, "{} must be < {} bytes" + .format(typename, name2size[typename])) + return v + + # Everything else is a hex string. + try: + v = bytes.fromhex(s) + except ValueError: + raise LineError(line, "Non-hex value for {}: '{}'" + .format(typename, s)) + if len(v) != name2size[typename]: + raise LineError(line, "{} must be {} bytes long not {}" + .format(typename, name2size[typename], len(v))) + return v + + def field_value(self, line, value): + """Decodes a value for this field: returns (fieldvalue, arrsize) + or (fieldvalue, None) if not an array""" + # If it's an array, expect a JSON array unless it's a byte array. + if self.arraylen or self.arrayvar: + if self.typename == 'byte': + try: + v = bytes.fromhex(value) + except ValueError: + raise LineError(line, + "Non-hex value for {} byte array: '{}'" + .format(self.name, value)) + # Known length? Check + if self.arraylen and len(v) != self.arraylen: + raise LineError(line, + "{} byte array should be length {} not {}" + .format(self.name, self.arraylen, len(v))) + return v, len(v) + else: + arr = [] + # Empty string doesn't quite do what we want with split. + if value == '': + values = [] + else: + values = value.split(',') + for v in values: + arr += [self.field_from_str(line, self.typename, + self.isinteger, v)] + # Known length? Check + if self.arraylen and len(arr) != self.arraylen: + raise LineError(line, + "{} array should be length {} not {}" + .format(self.name, self.arraylen, len(v))) + return arr, len(arr) + else: + return (self.field_from_str(line, + self.typename, self.isinteger, value), + None) + + def __repr__(self): + s = "{}:{}".format(self.name, self.typename) + if self.arraylen: + s += "[{}]".format(self.arraylen) + elif self.arrayvar: + s += "[{}]".format(self.arrayvar.name) + return s + + +class Message(object): + # * 0x8000 (BADONION): unparsable onion encrypted by sending peer + # * 0x4000 (PERM): permanent failure (otherwise transient) + # * 0x2000 (NODE): node failure (otherwise channel) + # * 0x1000 (UPDATE): new channel update enclosed + onion_types = {'BADONION': 0x8000, + 'PERM': 0x4000, + 'NODE': 0x2000, + 'UPDATE': 0x1000} + + def __init__(self, name, value): + self.name = name + self.value = self.parse_value(value) + self.fields = [] + + def parse_value(self, value): + result = 0 + for token in value.split('|'): + if token in self.onion_types.keys(): + result |= self.onion_types[token] + else: + result |= int(token) + + return result + + def findField(self, fieldname): + for f in self.fields: + if f.name == fieldname: + return f + return None + + def addField(self, field): + self.fields.append(field) + + def __repr__(self): + return "{}:{}:{}".format(self.name, self.value, self.fields) + + +def find_message(messages, name): + for m in messages: + if m.name == name: + return m + + return None + + +def read_csv(args): + for line in fileinput.input(args.csv_file): + parts = line.rstrip().split(',') + + if parts[0] == 'msgtype': + # eg msgtype,commit_sig,132 + messages.append(Message(parts[1], parts[2])) + elif parts[0] == 'msgdata': + m = find_message(messages, parts[1]) + if m is None: + raise ValueError('Unknown message {}'.format(parts[0])) + + # eg. msgdata,channel_reestablish,your_last_per_commitment_secret + # ,secret,,1option209 + m.addField(Field(m, parts[2], parts[3], parts[4], parts[5:])) + + +def parse_params(line, parts, compulsorykeys, optionalkeys=[]): + """Given an array of = make a dict, checking we have all compulsory +# keys.""" + ret = {} + for i in parts: + p = i.partition('=') + if p[1] != '=': + raise LineError(line, "Malformed key {} does not contain '='" + .format(i)) + if p[0] in ret.keys(): + raise LineError(line, "Duplicate key {}".format(p[0])) + if p[0] in compulsorykeys: + compulsorykeys.remove(p[0]) + elif p[0] in optionalkeys: + optionalkeys.remove(p[0]) + else: + raise LineError(line, "Unknown key {}".format(p[0])) + ret[p[0]] = p[2] + + if compulsorykeys != []: + raise LineError(line, "No specification for key {}" + .format(compulsorykeys[0])) + return ret + + +def check_hex(line, val, digits): + if not all(c in string.hexdigits for c in val): + raise LineError(line, "{} is not valid hex".format(val)) + if len(val) != digits: + raise LineError(line, "{} not {} characters long".format(val, digits)) + + +class Connection(object): + """Trivial class to represent a connection: often decorated by others""" + def __init__(self, connkey): + self.connkey = connkey + self.maybe_sends = [] + + def __str__(self): + return str(self.connkey) + +def optional_connection(line, params): + """Trivial helper to return & remove conn=key if specified, None if not""" + ret = params.pop('conn', None) + if ret is not None: + check_hex(line, ret, 64) + return ret + + +def which_connection(line, runner, connkey): + """Helper to get the conn they asked for, or default if connkey=None""" + if connkey is None: + if len(runner.connections) == 0: + raise LineError(line, "No active 'connect'") + return runner.connections[-1] + for c in runner.connections: + if c.connkey == connkey: + return c + raise LineError(line, "No active 'connect' {}".format(connkey)) + + +class NothingEvent(object): + def __init__(self, line, parts): + parse_params(line, parts, []) + + def action(self, runner, line): + pass + + +class ConnectEvent(object): + def __init__(self, line, parts): + self.privkey = parse_params(line, parts, ['privkey'])['privkey'] + check_hex(line, self.privkey, 64) + + def action(self, runner, line): + conn = Connection(self.privkey) + if conn.connkey in [c.connkey for c in runner.connections]: + raise LineError(line, + "Already have connection to {}".format(conn.connkey)) + runner.connections.append(conn) + runner.connect(conn, line) + + +class DisconnectEvent(object): + def __init__(self, line, parts): + d = parse_params(line, parts, [], ['conn']) + self.connkey = optional_connection(line, d) + + def action(self, runner, line): + conn = which_connection(line, runner, self.connkey) + runner.disconnect(conn, line) + runner.connections.remove(conn) + + +class RecvEvent(object): + def __init__(self, line, parts): + if len(parts) < 1: + raise LineError(line, "Missing type=") + t = parts[0].partition('=') + if t[1] != '=': + raise LineError(line, "Expected type=") + + msg = find_message(messages, t[2]) + if not msg: + # Allow raw integers. + msg = Message('unknown', t[2]) + + # See what fields are allowed. + fields = [] + optfields = ['conn', 'extra'] + for f in msg.fields: + # Lengths are implied + if f.islenvar: + continue + # Optional fields are, um, optional. + if f.options: + optfields.append(f.name) + else: + fields.append(f.name) + + # This fails if non-optional fields aren't specified. + d = parse_params(line, parts[1:], fields, optfields) + self.connkey = optional_connection(line, d) + + # Now get values for assembling the message. + values = {} + for f in msg.fields: + # Lengths are implied + if f.islenvar: + continue + if f.name not in d: + continue + value, vararrlen = f.field_value(line, d[f.name]) + values[f.name] = value + if f.arrayvar: + values[f.arrayvar.name] = vararrlen + + # BOLT #1: + # After decryption, all Lightning messages are of the form: + # + # 1. `type`: a 2-byte big-endian field indicating the type of message + # 2. `payload`: a variable-length payload that comprises the remainder + # of the message and that conforms to a format matching the `type` + self.b = struct.pack(">H", msg.value) + for f in msg.fields: + if f.name not in values: + continue + + v = values[f.name] + if f.arrayvar or f.arraylen: + for a in v: + self.b += pack(f.typename, a) + else: + self.b += pack(f.typename, v) + + if 'extra' in d: + self.b += bytes.fromhex(d['extra']) + + def action(self, runner, line): + runner.recv(which_connection(line, runner, self.connkey), + self.b, line) + + +def message_match(expectmsg, expectfields, b): + """Internal helper to see if b matches expectmsg & expectfields. + + Returns explanation string if it didn't match, otherwise None.""" + msgtype = struct.unpack_from(">H", b)[0] + off = 2 + + # Keep length fields + lenfields = {} + if msgtype != expectmsg.value: + return "Expected msg {} but got {}: {}".format(expectmsg.name, + msgtype, b.hex()) + for f in expectmsg.fields: + # If it's an array, we need the whole thing. + if f.arrayvar or f.arraylen: + if f.arrayvar: + num = lenfields[f.arrayvar.name] + else: + num = f.arraylen + # Array of bytes is special: treat raw. + if f.typename == 'byte': + v = b[off:off + num] + off += num + else: + v = [] + for i in range(0, num): + size, var = unpack_from(f.typename, b, off) + if size is None: + return ('Response too short to extract {}[{}]: {}' + .format(f.name, i, b.hex())) + off += size + v += [var] + else: + size, v = unpack_from(f.typename, b, off) + if size is None: + # Optional fields might not exist + if f.options != []: + v = None + size = 0 + else: + return ('Response too short to extract {}: {}' + .format(f.name, b.hex())) + off += size + + # If it's used as a length, save it. + if f.islenvar: + lenfields[f.name] = int(v) + + # They expect a value from this. + if f.name in expectfields: + exp = expectfields[f.name] + + # If they specify field=absent, it must not be there. + if exp is None: + if v is not None: + return "Field {} is present" + else: + continue + + if v is None: + return ("Optional field {} is not present in {}" + .format(f.name, b.hex())) + if isinstance(exp, tuple): + # Out-of-range bitmaps are considered 0 (eg. feature tests) + if len(v) < len(exp[0]): + cmpv = b'\x00' * (len(exp[0]) - len(v)) + v + elif len(v) > len(exp[0]): + cmpv = v[-len(exp[0]):] + else: + cmpv = v + + for i in range(0, len(exp[0])): + if cmpv[i] & exp[1][i] != exp[0][i]: + return ("Expected {}.{} mask 0x{}" + " value 0x{} but got 0x{}" + " (offset {} different):" + " {}" + .format(expectmsg.name, f.name, + exp[1].hex(), exp[0].hex(), + v.hex(), len(exp[0]) - 1 - i, + b.hex())) + # Simple comparison + elif v != exp: + if f.isinteger: + valstr = str(v) + expectstr = str(exp) + else: + valstr = v.hex() + expectstr = exp.hex() + return ("Expected {}.{} {} but got {}: {}" + .format(expectmsg.name, + f.name, expectstr, valstr, b.hex())) + return None + + +def maybesend_match(conn, msg): + """Internal helper to see if msg matches one of the previous maybe-sends""" + for m in conn.maybe_sends: + failreason = message_match(m.expectmsg, m.expectfields, msg) + if failreason is None: + conn.maybe_sends.remove(m) + return True + + return False + + +class ExpectSendEvent(object): + def __init__(self, line, parts, maybe=False): + self.line = line + self.maybe = maybe + if len(parts) < 1: + raise LineError(line, "Missing type=") + t = parts[0].partition('=') + if t[1] != '=': + raise LineError(line, "Expected type=") + + self.expectmsg = find_message(messages, t[2]) + if not self.expectmsg: + raise LineError(line, "Unknown message type") + self.expectfields = {} + + optfields = ['conn'] + for f in self.expectmsg.fields: + # Lengths are implied + if f.islenvar: + continue + optfields.append(f.name) + + # All fields are optional + d = parse_params(line, parts[1:], [], optfields) + self.connkey = optional_connection(line, d) + + for v in d.keys(): + # IDENTIFIER`=`FIELDVALUE | IDENTIFIER`=`HEX/HEX | `absent` + f = self.expectmsg.findField(v) + + parts = d[v].partition('/') + if parts[1] == '/': + self.expectfields[v] = (bytes.fromhex(parts[0]), + bytes.fromhex(parts[2])) + if len(self.expectfields[v][0]) != len(self.expectfields[v][1]): + raise LineError(line, "Unequal value/mask lengths") + else: + if parts[0] == 'absent': + if f.options == []: + raise LineError(line, "Field is not optional") + self.expectfields[v] = None + else: + self.expectfields[v], _ = f.field_value(line, parts[0]) + + def __repr__(self): + if self.maybe: + return "maybe-send:{}:{}".format(self.expectmsg.name, self.line) + return "expect-send:{}:{}".format(self.expectmsg.name, self.line) + + def action(self, runner, line): + conn = which_connection(line, runner, self.connkey) + # If this is 'maybe-send' then just add it to maybe list. + if self.maybe: + conn.maybe_sends.append(self) + return + + msg = runner.expect_send(conn, line) + + # We let the dummy runner "pass" always. + if type(runner) == DummyRunner: + return + + while True: + failreason = message_match(self.expectmsg, self.expectfields, msg) + if failreason is None: + return + + if maybesend_match(conn, msg): + msg = runner.expect_send(conn, line) + else: + break + + if conn.maybe_sends != []: + raise ValidationError(line, + failreason + + " (and none of {})".format(conn.maybe_sends)) + raise ValidationError(line, failreason) + + +class BlockEvent(object): + def __init__(self, line, parts): + # Since parse_params doesn't allow dups, feed it one part at a time + self.blockheight = int(parse_params(line, [parts[0]], ['height'])['height']) + self.txs = [] + self.n = 1 + + # Since parse_params doesn't allow dups, feed it one part at a time + for i in range(1, len(parts)): + # n is only valid as first arg. + if i == 1: + d = parse_params(line, [parts[i]], [], ['n', 'tx']) + if 'n' in d: + if self.n != 1: + raise LineError(line, "Can't specify n more than once") + self.n = int(d['n']) + continue + else: + d = parse_params(line, [parts[i]], ['tx']) + self.txs.append(d['tx']) + + def action(self, runner, line): + # Oops, did they ask us to produce a block with no predecessor? + if runner.getblockheight() + 1 < self.blockheight: + raise LineError(line, "Cannot generate block #{} at height {}". + format(self.blockheight, runner.getblockheight())) + + # Throw away blocks we're replacing. + if runner.getblockheight() >= self.blockheight: + runner.trim_blocks(self.blockheight - 1) + + # Add new one + runner.add_blocks(self.txs, self.n, line) + assert runner.getblockheight() == self.blockheight - 1 + self.n + + +class ExpectTxEvent(object): + def __init__(self, line, parts): + self.tx = bytes.fromhex(parse_params(line, parts, ['tx'])['tx']) + + def action(self, runner, line): + runner.expect_tx(self.tx, line) + + +class FundChannelEvent(object): + def __init__(self, line, parts): + d = parse_params(line, parts, ['amount', 'utxo'], ['conn']) + self.connkey = optional_connection(line, d) + self.amount = int(d['amount']) + parts = d['utxo'].partition('/') + check_hex(line, parts[0], 66) + self.utxo = (parts[0], int(parts[2])) + + def action(self, runner, line): + runner.fundchannel(which_connection(line, runner, self.connkey), + self.amount, self.utxo[0], + self.utxo[1], line) + + +class InvoiceEvent(object): + def __init__(self, line, parts): + d = parse_params(line, parts, ['amount', 'preimage']) + self.preimage = d['preimage'] + check_hex(line, self.preimage, 64) + self.amount = int(d['amount']) + + def action(self, runner, line): + runner.invoice(self.amount, self.preimage, line) + + +class ExpectErrorEvent(object): + def __init__(self, line, parts): + d = parse_params(line, parts, [], ['conn']) + self.connkey = optional_connection(line, d) + + def action(self, runner, line): + runner.expected_error = True + runner.expect_error(which_connection(line, runner, self.connkey), line) + + +class Event(object): + def __init__(self, args, desc, line): + self.args = args + self.line = copy(line) + + parts = desc.split() + self.event = parts[0] + + if parts[0] == 'connect:': + self.actor = ConnectEvent(line, parts[1:]) + elif parts[0] == 'disconnect:': + self.actor = DisconnectEvent(line, parts[1:]) + elif parts[0] == 'recv:': + self.actor = RecvEvent(line, parts[1:]) + elif parts[0] == 'expect-send:': + self.actor = ExpectSendEvent(line, parts[1:]) + elif parts[0] == 'maybe-send:': + self.actor = ExpectSendEvent(line, parts[1:], maybe=True) + elif parts[0] == 'block:': + self.actor = BlockEvent(line, parts[1:]) + elif parts[0] == 'expect-tx:': + self.actor = ExpectTxEvent(line, parts[1:]) + elif parts[0] == 'fundchannel:': + self.actor = FundChannelEvent(line, parts[1:]) + elif parts[0] == 'invoice:': + self.actor = InvoiceEvent(line, parts[1:]) + elif parts[0] == 'expect-error:': + self.actor = ExpectErrorEvent(line, parts[1:]) + elif parts[0] == 'nothing': + self.actor = NothingEvent(line, parts[1:]) + else: + raise ValueError("Unknown event type {}".format(parts[0])) + + def __repr__(self): + return "Event({}, {})".format(self.event, str(self.line)) + + def flatten(self, number, stopline, prefix=''): + # Nothing doesn't even need outputting + if type(self.actor) == NothingEvent: + return False, number + return self.line.flatten(number, stopline, prefix) + + def num_steps(self): + return 1 + + def act(self, runner): + if self.args.verbose: + print("# running {}".format(self)) + self.actor.action(runner, self.line) + + +class Sequence(object): + """Ordered sequence of Events""" + def __init__(self, args): + self.args = args + self.events = [] + self.line = None + + def add_event(self, e): + self.events.append(e) + if self.line is None: + self.line = copy(e.line) + else: + self.line += e.line + + def flatten(self, number, stopline, prefix=''): + stop = False + for e in self.events: + stop, number = e.flatten(number, stopline, prefix) + if stop: + break + return stop, number + + def num_steps(self): + return sum([e.num_steps() for e in self.events]) + + def __str__(self): + return "{}".format(self.line) + + def __repr__(self): + return "Sequence:{}".format(self) + + def run(self, runner, start=0): + if self.args.verbose: + print("# running {}:".format(self)) + for e in self.events[start:]: + e.act(runner) + + +class OneOfEvent(object): + """Event representing multiple possible sequences""" + def __init__(self, args, line): + self.line = line + self.args = args + self.sequences = [] + + def __str__(self): + return str(self.line) + + def flatten(self, number, stopline, prefix): + # FIXME: if stopline is in here, we ignore it + _, number = self.line.flatten(number, stopline, prefix) + i = 1 + for s in self.sequences: + _, i = s.flatten(i, stopline, ' ') + return False, number + + def num_steps(self): + # Use the mean of the separate sequences as a guesstimate. + return sum([s.num_steps() for s in self.sequences]) / len(self.sequences) + + def add_sequence(self, seq): + actor = seq.events[0].actor + if type(actor) != ExpectSendEvent: + # We could relax this a bit if necessary, eg 'expect-error' or + # 'expect-tx' would be possible. + raise LineError(seq.events[0].line, + "First sequence event in One Of must be expect-send") + # They have to match on what conn the specify, too. + if len(self.sequences) != 0: + if actor.connkey != self.connkey: + raise LineError(seq.events[0].line, + "All first sequence event in One Of must same conn=") + else: + self.connkey = actor.connkey + self.sequences.append(seq) + + def act(self, runner): + if self.args.verbose: + print("# running {}".format(self)) + + # For DummyRunner, we assume the first. + if type(runner) == DummyRunner: + return self.sequences[0].run(runner) + + conn = which_connection(self.line, runner, self.connkey) + while True: + msg = runner.expect_send(conn, self.line) + for s in self.sequences: + failreason = message_match(s.events[0].actor.expectmsg, + s.events[0].actor.expectfields, msg) + if failreason is None: + # We found the sequence, run the rest of it. + s.run(runner, start=1) + return + + if maybesend_match(conn, msg): + continue + + raise ValidationError(self.line, + "None of the sequences matched {}" + .format(msg.hex())) + +# Loads a Sequence at this indent level (and any children embedded in +# it, if allow_children). Returns the initial Sequence, a list of +# Sequence leaves, and the next linenum. +def load_sequence(args, lines, linenum, indentlevel, graph): + count = 1 + init_seq = Sequence(args) + + seq = init_seq + terminals = [seq] + + if graph is not None: + graph.add_node(seq) + + # We always parse one child. + if lines[linenum].indentlevel != indentlevel: + raise LineError(lines[linenum], "Expected {} indents.", indentlevel) + if not lines[linenum].line.startswith('1.'): + raise LineError(lines[linenum], "Expected 1.") + + while linenum < len(lines): + # Unindent? We're done. + if lines[linenum].indentlevel < indentlevel: + return init_seq, terminals, linenum + + # Indent? Parse children. + if lines[linenum].indentlevel == indentlevel + 1: + if graph is None: + raise LineError(lines[linenum], + "Cannot have indentations inside 'One of'") + child, childterms, linenum = load_sequence(args, + lines, linenum, + indentlevel + 1, graph) + + # Attach this child to our current seq. + if args.verbose: + print("# child {} -> {}".format(seq, child)) + + graph.add_edge(seq, child) + + # Seq is no longer terminal + if seq in terminals: + terminals.remove(seq) + + # These will bet attached onto the next sequence. + terminals += childterms + continue + elif lines[linenum].indentlevel != indentlevel: + raise LineError(lines[linenum], "Unexpected indent.") + + # Same level. + parts = lines[linenum].line.partition('.') + if parts[1] != '.': + raise LineError(lines[linenum], + "Expected '{}.' or '1.'".format(count)) + + # Unexpected 1. means a new start. + if parts[0] != str(count): + return init_seq, terminals, linenum + + if parts[2].split() == ['One', 'of:']: + event = OneOfEvent(args, lines[linenum]) + + # We expect indented sequences + linenum += 1 + while lines[linenum].indentlevel == indentlevel + 1: + # We don't allow sub-nodes here, so terminals will be [child] + child, _, linenum = load_sequence(args, lines, linenum, + indentlevel + 1, + None) + event.add_sequence(child) + + if event.sequences == []: + raise LineError(lines[linenum], + "Expected indented sequences after 'One of:'") + else: + event = Event(args, parts[2], lines[linenum]) + linenum += 1 + + # Any children from last step, start new Sequence for them to connect. + if terminals != [seq]: + seq = Sequence(args) + seq.add_event(event) + graph.add_node(seq) + for c in terminals: + if args.verbose: + print("# {} -> {}".format(c, seq)) + graph.add_edge(c, seq) + terminals = [seq] + else: + seq.add_event(event) + count += 1 + + # Any children will continue from our last event(s). + return init_seq, terminals, linenum + + +def run_test(args, path, runner): + if args.verbose: + print("## RESTART") + runner.restart() + runner.connections = [] + runner.expected_error = False + for seq in path: + seq.run(runner) + if not runner.expected_error: + error = runner.final_error() + if error is not None: + raise ValidationError(None, + "Unexpected error occurred: {}".format(error)) + + +def line_minus_comments(verbose, line, linenum): + """Strips any comment from a line, and trailing whitespace.""" + # Get the line. + arr = line.rstrip().partition('#') + if arr[1] == '#' and verbose: + if arr[2] != '': + print("# {}: {}".format(linenum, arr[2])) + return arr[0].rstrip() + + +def filter_out(args, line, filename, linenum): + """Trim options: we discard the line if it doesn't qualify.""" + while True: + m = re.search("(?P!?)" + "(?Popt[A-Za-z_]*)" + r"(?P(/(odd|even))?)\s*$", line) + if m is None: + return line + + if m.group('oddoreven') != '': + present = m.group('optname') + m.group('oddoreven') in args.option + else: + present = (m.group('optname') + '/odd' in args.option + or m.group('optname') + '/even' in args.option) + + # If option was specified as --option, invert must be set. + wanted = m.group('invert') != '!' + if present != wanted: + if args.verbose: + print("# Removing line {}: requires {}{}{}" + .format(Line(filename, linenum, linenum, 0, line), + m.group('invert'), + m.group('optname'), + m.group('oddoreven'))) + return '' + line = line[:m.start()] + + +def indentation(s): + """Returns str with indent stripped, and effectve indentation amount""" + level = 0 + consumed = 0 + for i in range(len(s)): + if s[i] == ' ': + level += 1 + elif s[i] == '\t': + # I keep puttiing in tabs by mistake. Make them got to next 8. + level = (level + 8) // 8 * 8 + else: + break + consumed = i+1 + return s[consumed:], level + + +def parse_file(args, f, filename, variables): + """Get non-comment lines, as [(linenums,indentlevel,line)], grab vars""" + content = [] + lines = f.readlines() + i = 0 + while i < len(lines): + line_start = i + + line = line_minus_comments(args.verbose, lines[i], line_start) + line = filter_out(args, line, filename, line_start) + if line == '': + i += 1 + continue + + # Store indentation level, remove it. + line, indent = indentation(line) + if indent % 4 != 0: + raise LineError(Line(filename, line_start, line_start, 0, line), + "Indent is not a multiple of 4!") + indentlevel = indent // 4 + + i += 1 + line_end = line_start + + # Grab any continuation lines + while i < len(lines): + lookahead = line_minus_comments(False, lines[i], i) + if lookahead == '': + i += 1 + continue + lookahead, indent = indentation(lookahead) + # Line continuations are non-4 indent, but must be greater. + if indent % 4 == 0: + break + if indent < indentlevel * 4: + raise LineError(Line(filename, i, i, indentlevel, lines[i]), + "Indent is not a multiple of 4!") + line += ' ' + filter_out(args, lookahead, filename, i) + line_end = i + i += 1 + + # Expand variables. + while True: + m = re.search(r"\$(?P[A-Za-z_0-9]+)", line) + if m is None: + break + + if not m.group('varname') in variables: + raise LineError(Line(filename, i, i, indentlevel, lines[i]), + "Unknown variable {}".format(m.group('varname'))) + + line = (line[:m.start()] + + variables[m.group('varname')] + + line[m.end():]) + + # Check if we're merely setting a variable; we do this now so + # we can expand inside parse_file itself. + parts = line.partition('=') + if parts[1] == '=' and re.fullmatch('[A-Za-z0-9_]+', parts[0]): + if parts[0] in variables: + raise LineError(Line(filename, line_start, line_end, + indentlevel, lines[i]), + "Re-setting var {}".format(parts[0])) + variables[parts[0]] = parts[2] + # Similarly, do include directives immediately. + elif line.startswith('include '): + # Filenames are assumed to be relative. + subfilename = path.join(path.dirname(filename), line[8:]) + subf = open(subfilename) + # This can set, and use, variables. + sublines, variables = parse_file(args, subf, subfilename, variables) + # Indent entire file as per this include line. + for l in sublines: + l.indentlevel += indentlevel + content += sublines + else: + content.append(Line(filename, line_start, line_end, indentlevel, + line)) + + return content, variables + + +def main(args, runner): + read_csv(args) + if args.verbose: + print("# loaded {} message types".format(len(messages))) + + lines = [] + for filename in args.input: + if filename is None: + filename = '' + f = sys.stdin + else: + f = open(filename) + + lines, _ = parse_file(args, f, filename, {}) + f.close() + + graph = nx.DiGraph() + root, terminals, linenum = load_sequence(args, lines, 0, 0, graph) + + # We only support one root sequence for now. + if linenum != len(lines): + raise LineError(lines[linenum], + "Unexpected lines after end of first sequence") + + if args.draw_events: + labels = {} + for seq in graph.nodes(): + labels[seq] = str(seq) + + nx.draw_circular(graph, labels=labels, node_size=50, font_size=4) + plt.savefig(filename + ".png", dpi=300) + + # Edge weight == ops in sequence it leads to. Since we walk + # most-expensive-first, this gives maximum testing coverage to + # first run. + for e in graph.edges(): + graph.edges[e]['weight'] = e[1].num_steps() + + # Get all paths + paths = [] + if args.via: + parts = args.via.partition(':') + if parts[1] == ':': + filename = parts[0] + linenum = int(parts[2]) + else: + filename = None + linenum = int(parts[0]) + via = None + for seq in graph.nodes(): + if filename and seq.line.filename != filename: + continue + if linenum < seq.line.linestart: + continue + if linenum > seq.line.lineend: + continue + via = seq + break + + if not via: + raise ValueError("{} not found".format(args.destination)) + + path1 = nx.shortest_path(graph, root, via, 'weight') + + # Now get to any terminal. + for t in terminals: + try: + path2 = nx.shortest_path(graph, via, t, 'weight') + break + except nx.exception.NetworkXNoPath: + pass + paths = [path1 + path2] + elif args.exhaustive: + # This does the simple ones first, which is usually what + # you want. + for t in terminals: + paths += nx.shortest_simple_paths(graph, root, t, 'weight') + else: + while any([graph.edges[e]['weight'] != 0 for e in graph.edges()]): + for t in terminals: + # Start with "longest" first. This is a super slow way + # to calc this! + path = list(nx.shortest_simple_paths(graph, root, t, 'weight'))[-1] + new_edge = False + for e in nx.utils.misc.pairwise(path): + if graph.edges[e]['weight'] > 0: + new_edge = True + graph.edges[e]['weight'] = 0 + + if new_edge: + if args.verbose: + print("PATH: {}".format(path)) + paths.append(path) + break + + # Special case of a single sequence + if graph.number_of_nodes() == 1: + paths = [[root]] + + if not args.verbose: + print("{}:{} paths: ".format(filename, len(paths)), end='', flush=True) + for path in paths: + try: + run_test(args, path, runner) + except ValidationError as v: + print("ERROR during {}".format([p.line for p in path]), file=sys.stderr) + if args.flatten_failpath: + index = 1 + print("FAILPATH to {}:".format(v.line)) + for p in path: + stop, index = p.flatten(index, v.line) + if stop: + break + raise + if not args.verbose: + print('.', end='', flush=True) + print("OK") + + +if __name__ == "__main__": + parser = setup_cmdline_options() + args = parser.parse_args() + + main(args, DummyRunner(args)) From 077af841c2f33fb60fe06cb7e4057001fa803a56 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:26 +0930 Subject: [PATCH 039/103] tests: c-lightning support. Works with current c-lightning master branch, as long as it's built with --enable-developer. Signed-off-by: Rusty Russell --- tools/test-events-clightning.py | 297 ++++++++++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100755 tools/test-events-clightning.py diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py new file mode 100755 index 000000000..6b8972c72 --- /dev/null +++ b/tools/test-events-clightning.py @@ -0,0 +1,297 @@ +#! /usr/bin/python3 +# This script exercises the c-lightning implementation + +# Released by Rusty Russell under CC0: +# https://creativecommons.org/publicdomain/zero/1.0/ + +import bitcoin +import bitcoin.rpc +import importlib +import lightning +import os +import shutil +import struct +import subprocess +import tempfile +import time + +from concurrent import futures +from ephemeral_port_reserve import reserve + +test = importlib.import_module('test-events') + +TIMEOUT = int(os.getenv("TIMEOUT", "30")) +LIGHTNING_SRC = os.getenv("LIGHTNING_SRC", '../lightning/') + + +def wait_for(success, timeout=TIMEOUT): + start_time = time.time() + interval = 0.25 + while not success() and time.time() < start_time + timeout: + time.sleep(interval) + interval *= 2 + if interval > 5: + interval = 5 + return time.time() <= start_time + timeout + +# Stolen from lightning/tests/utils.py +class SimpleBitcoinProxy: + """Wrapper for BitcoinProxy to reconnect. + + Long wait times between calls to the Bitcoin RPC could result in + `bitcoind` closing the connection, so here we just create + throwaway connections. This is easier than to reach into the RPC + library to close, reopen and reauth upon failure. + """ + def __init__(self, btc_conf_file, *args, **kwargs): + self.__btc_conf_file__ = btc_conf_file + + def __getattr__(self, name): + if name.startswith('__') and name.endswith('__'): + # Python internal stuff + raise AttributeError + + # Create a callable to do the actual call + proxy = bitcoin.rpc.RawProxy(btc_conf_file=self.__btc_conf_file__) + + def f(*args): + return proxy._call(name, *args) + + # Make debuggers show rather than > + f.__name__ = name + return f + + +class Bitcoind(object): + """Starts regtest bitcoind on an ephemeral port, and returns the RPC proxy""" + def __init__(self, basedir): + self.bitcoin_dir = os.path.join(basedir, "bitcoind") + if not os.path.exists(self.bitcoin_dir): + os.makedirs(self.bitcoin_dir) + self.bitcoin_conf = os.path.join(self.bitcoin_dir, 'bitcoin.conf') + self.cmd_line = [ + 'bitcoind', + '-datadir={}'.format(self.bitcoin_dir), + '-server', + '-regtest', + '-logtimestamps', + '-nolisten'] + self.port = reserve() + print("Port is {}, dir is {}".format(self.port, self.bitcoin_dir)) + # For after 0.16.1 (eg. 3f398d7a17f136cd4a67998406ca41a124ae2966), this + # needs its own [regtest] section. + with open(self.bitcoin_conf, 'w') as f: + f.write("regtest=1\n") + f.write("rpcuser=rpcuser\n") + f.write("rpcpassword=rpcpass\n") + f.write("[regtest]\n") + f.write("rpcport={}\n".format(self.port)) + self.rpc = SimpleBitcoinProxy(btc_conf_file=self.bitcoin_conf) + + def start(self): + self.proc = subprocess.Popen(self.cmd_line, stdout=subprocess.PIPE) + + # Wait for it to startup. + while b'Done loading' not in self.proc.stdout.readline(): + pass + + # Block #1. + self.rpc.submitblock('0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f7b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d04283f5a1095dffff7f200100000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0200f2052a01000000160014751e76e8199196d454941c45d1b3a323f1433bd60000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000') + self.rpc.generatetoaddress(100, self.rpc.getnewaddress()) + # This goes into block #101, now we can spend coinbase from #1. + self.rpc.sendrawtransaction('020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000') + self.rpc.generatetoaddress(1, self.rpc.getnewaddress()) + + def stop(self): + self.proc.kill() + + def restart(self): + # Only restart if we have to. + if self.rpc.getblockcount() != 102 or self.rpc.getrawmempool() == []: + self.stop() + shutil.rmtree(os.path.join(self.bitcoin_dir, 'regtest')) + self.start() + + +class CLightningRunner(object): + def __init__(self, args): + self.connections = [] + directory = tempfile.mkdtemp(prefix='test-events-') + self.bitcoind = Bitcoind(directory) + self.bitcoind.start() + self.executor = futures.ThreadPoolExecutor(max_workers=20) + + self.lightning_dir = os.path.join(directory, "lightningd") + if not os.path.exists(self.lightning_dir): + os.makedirs(self.lightning_dir) + self.lightning_port = reserve() + + def start(self): + self.proc = subprocess.Popen(['{}/lightningd/lightningd'.format(LIGHTNING_SRC), + '--lightning-dir={}'.format(self.lightning_dir), + '--funding-confirms=3', + '--dev-force-privkey=0000000000000000000000000000000000000000000000000000000000000001', + '--dev-force-bip32-seed=0000000000000000000000000000000000000000000000000000000000000001', + '--dev-force-channel-secrets=0000000000000000000000000000000000000000000000000000000000000010/0000000000000000000000000000000000000000000000000000000000000011/0000000000000000000000000000000000000000000000000000000000000012/0000000000000000000000000000000000000000000000000000000000000013/0000000000000000000000000000000000000000000000000000000000000014/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', + '--dev-bitcoind-poll=1', + '--bind-addr=127.0.0.1:{}'.format(self.lightning_port), + '--network=regtest', + '--bitcoin-rpcuser=rpcuser', + '--bitcoin-rpcpassword=rpcpass', + '--bitcoin-rpcport={}'.format(self.bitcoind.port), + '--log-level=debug', + '--log-file=log']) + self.rpc = lightning.LightningRpc(os.path.join(self.lightning_dir, "lightning-rpc")) + + def node_ready(rpc): + try: + rpc.getinfo() + return True + except Exception: + return False + + if not wait_for(lambda: node_ready(self.rpc)): + raise subprocess.TimeoutExpired(self.proc, + "Could not contact lightningd") + + def stop(self): + self.rpc.stop() + self.bitcoind.stop() + for c in self.connections: + c.proc.kill() + + def __enter__(self): + self.start() + return self + + def __exit__(self, type, value, tb): + self.stop() + + def restart(self): + self.rpc.stop() + self.bitcoind.restart() + for c in self.connections: + c.proc.kill() + + # Make a clean start + os.remove(os.path.join(self.lightning_dir, "gossip_store")) + os.remove(os.path.join(self.lightning_dir, "lightningd.sqlite3")) + os.remove(os.path.join(self.lightning_dir, "log")) + self.start() + + def connect(self, conn, line): + # FIXME: Open-code the lightning enc protocol in Python! + conn.proc = subprocess.Popen(['{}/devtools/gossipwith'.format(LIGHTNING_SRC), + '--privkey={}'.format(conn.connkey), + '--stdin', + '--no-init', + '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798@localhost:{}'.format(self.lightning_port)], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + bufsize=0) + + def getblockheight(self): + return self.bitcoind.rpc.getblockcount() + + def trim_blocks(self, newheight): + h = self.bitcoind.rpc.getblockhash(newheight + 1) + self.bitcoind.rpc.invalidateblock([h]) + + def add_blocks(self, txs, n, line): + for tx in txs: + self.bitcoind.rpc.sendrawtransaction(tx) + self.bitcoind.rpc.generatetoaddress(n, self.bitcoind.rpc.getnewaddress()) + + if not wait_for(lambda: self.rpc.getinfo()['blockheight'] == self.getblockheight()): + raise test.ValidationError(line, + "Node did not sync to blockheight:" + " {} vs {}" + .format(self.rpc.getinfo()['blockheight'], + self.getblockheight())) + + def disconnect(self, conn, line): + # FIXME: Inject a bad enc packet, so it hangs up on us *after* + # processing + time.sleep(1) + conn.proc.terminate() + conn.proc.wait(30) + + def recv(self, conn, outbuf, line): + rawl = struct.pack('>H', len(outbuf)) + conn.proc.stdin.write(rawl) + + while len(outbuf) != 0: + written = conn.proc.stdin.write(outbuf) + outbuf = outbuf[written:] + + # FIXME: Implement fundchannel. + # We'll need to import privkey into bitcoind and hand-generate the tx + # then use fundchannel_start. + + def invoice(self, amount, preimage, line): + self.rpc.invoice(msatoshi=amount, + label=str(line), + description='invoice from {}'.format(line), + preimage=preimage) + + def expect_send(self, conn, line, timeout=TIMEOUT): + def readmsg(conn): + rawl = conn.proc.stdout.read(2) + length = struct.unpack('>H', rawl)[0] + msg = bytes() + while len(msg) < length: + msg += conn.proc.stdout.read(length - len(msg)) + return msg + + fut = self.executor.submit(readmsg, conn) + try: + return fut.result(timeout) + except futures.TimeoutError: + raise test.ValidationError(line, "Timed out") + + def expect_tx(self, tx, line): + def tx_in_mempool(tx): + for txid in self.bitcoind.rpc.getrawmempool(): + if self.bitcoind.rpc.getrawtransaction(txid) == tx: + return True + return False + + # This tx should appear in the mempool. + if not wait_for(lambda: tx_in_mempool(tx)): + raise test.ValidationError(line, "Did not broadcast the transaction") + + def expect_error(self, conn, line): + while True: + msg = self.expect_send(conn, line) + + # If we got an error, mark it + if struct.unpack('>H', msg[0:2]) == (17,): + return + + def final_error(self): + # Just make sure it doesn't send an ERROR, but only give it 1 second. + # FIXME: We should just use poll to see if any output pending! + for c in self.connections: + try: + msg = self.expect_send(c, None, 1) + # If we got an error, mark it + if struct.unpack('>H', msg[0:2]) == (17,): + return msg.hex() + except test.ValidationError: + pass + return None + + +if __name__ == "__main__": + parser = test.setup_cmdline_options() + args = parser.parse_args() + # Here are the options we support. + args.option += ['option_data_loss_protect/odd', + 'option_initial_routing_sync/odd', + 'option_upfront_shutdown_script/odd', + 'option_gossip_queries/odd'] + + # We use a context here, so we can always kill processes at exit + with CLightningRunner(args) as runner: + test.main(args, runner) From d940f77a81accde0d8f59ec6ac9face04447d6b2 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:28 +0930 Subject: [PATCH 040/103] tests: channel opening test. Very simple successful open. Signed-off-by: Rusty Russell --- tests/events/bolt2-01-open_channel.events | 78 +++++++++++++++++++++++ tests/events/test-spec.md | 15 +++++ 2 files changed, 93 insertions(+) create mode 100644 tests/events/bolt2-01-open_channel.events diff --git a/tests/events/bolt2-01-open_channel.events b/tests/events/bolt2-01-open_channel.events new file mode 100644 index 000000000..7083f26c8 --- /dev/null +++ b/tests/events/bolt2-01-open_channel.events @@ -0,0 +1,78 @@ +# Variations on open_channel. + +1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +2. expect-send: type=init +3. recv: type=init globalfeatures= localfeatures= + + # We assume a funding_per_kw=253 Satoshi/kSipa. + # This gives a channel of 999878sat + 1. recv: type=open_channel + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + funding_satoshis=999878 + push_msat=0 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=4294967295 + channel_reserve_satoshis=9998 + htlc_minimum_msat=0 + feerate_per_kw=253 + to_self_delay=6 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 + funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000021 + revocation_basepoint=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000022 + payment_basepoint=031be68a5a028f2601d0e80d468c344ba331d611b96c358b6032e8b4da0547fc11 + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000023 + delayed_payment_basepoint=03605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479 + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000024 + htlc_basepoint=02e0392cfa338aaf2f0b56c563e3e5e67a5d5fefe3388f85d90c899da20f0198f9 + # shachain seed=0000000000000000000000000000000000000000000000000000000000000000 + # first per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 + channel_flags=01 + + 2. expect-send: type=accept_channel + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 + funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000011 + revocation_basepoint=03defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000012 + payment_basepoint=025601570cb47f238d2b0286db4a990fa0f3ba28d1a319f5e7cf55c2a2444da7cc + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000013 + delayed_payment_basepoint=022b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000014 + htlc_basepoint=024ce119c96e2fa357200b559b2f7dd5a5f02d5290aff74b03f3e471b273211c97 + # shachain seed=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + # first per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + first_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 + minimum_depth=3 + # If these are different, the commitment tx will be different! + to_self_delay=6 + channel_reserve_satoshis=9998 + + 3. recv: type=funding_created + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f + funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + funding_output_index=0 + # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 + signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + + 4. expect-send: type=funding_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 + signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + + 5. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + + 6. expect-send: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + + 7. recv: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index 7ffcc41c4..dc505d2c3 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -150,6 +150,21 @@ The peer secret of the test node is assumed which makes its public key `0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`. +The `minimum_depth` setting of the test node is assumed to be 3. + +The following secrets are used for the first channel (if successive +channels exist in tests, they are only used for gossip test and their +exact configuration is not tested); it's assumed that RFC6979 (using +HMAC-SHA256) is used to generate transaction signatures. + + funding_privkey: 0000000000000000000000000000000000000000000000000000000000000010 + revocation_basepoint_secret: 0000000000000000000000000000000000000000000000000000000000000011 + payment_basepoint_secret: 0000000000000000000000000000000000000000000000000000000000000012 + delayed_payment_basepoint_secret: 0000000000000000000000000000000000000000000000000000000000000013 + htlc_basepoint_secret: 0000000000000000000000000000000000000000000000000000000000000014 + per_commitment_secret_seed: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + + ## Blockchain Setup The initial blockchain is a bitcoind `regtest` chain, which has the From 8e46a95c2d0c95156ebbc7f607436deab7bb300e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:28 +0930 Subject: [PATCH 041/103] tests: HTLC-adding test. Does a simple dust HTLC and a non-dust HTLC. Both fail. Signed-off-by: Rusty Russell --- tests/events/bolt2-02-add-htlc.events | 174 ++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 tests/events/bolt2-02-add-htlc.events diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events new file mode 100644 index 000000000..289c0da84 --- /dev/null +++ b/tests/events/bolt2-02-add-htlc.events @@ -0,0 +1,174 @@ +# Variations on open_channel. + +1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +2. expect-send: type=init +3. recv: type=init globalfeatures= localfeatures=02 +4. recv: type=open_channel + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + funding_satoshis=999878 + push_msat=0 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=4294967295 + channel_reserve_satoshis=9998 + htlc_minimum_msat=0 + feerate_per_kw=253 + to_self_delay=6 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 + funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000021 + revocation_basepoint=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000022 + payment_basepoint=031be68a5a028f2601d0e80d468c344ba331d611b96c358b6032e8b4da0547fc11 + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000023 + delayed_payment_basepoint=03605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479 + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000024 + htlc_basepoint=02e0392cfa338aaf2f0b56c563e3e5e67a5d5fefe3388f85d90c899da20f0198f9 + # shachain seed=0000000000000000000000000000000000000000000000000000000000000000 + # first per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 + channel_flags=01 + +5. expect-send: type=accept_channel + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 + funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000011 + revocation_basepoint=03defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000012 + payment_basepoint=025601570cb47f238d2b0286db4a990fa0f3ba28d1a319f5e7cf55c2a2444da7cc + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000013 + delayed_payment_basepoint=022b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000014 + htlc_basepoint=024ce119c96e2fa357200b559b2f7dd5a5f02d5290aff74b03f3e471b273211c97 + # shachain seed=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + # per_commitment_secret #0=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + first_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 + # If these are different, the commitment tx will be different! + to_self_delay=6 + channel_reserve_satoshis=9998 + +6. recv: type=funding_created + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f + funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + funding_output_index=0 + # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 + signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + +7. expect-send: type=funding_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 + signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + +8. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + +9. expect-send: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + +10. recv: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # per_commitment_secret #1 = dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 + next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d + +11. maybe-send: type=channel_update + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + # FIXME: Fill other expected fields here! + +# Add a dust HTLC + 1. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + amount_msat=1000 + # preimage=0000000000000000000000000000000000000000000000000000000000000000 + payment_hash=66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000003E8000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd9f755853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b3113cbed88e6cfb566f7a693bb63c9a89925c1f5df0a115b4893128866a81c1b + + 2. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c + htlc_signature= + + 3. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + + 4. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + htlc_signature= + + 5. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a + next_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad + + # Add a non-dust HTLC + 1. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + amount_msat=1000000 + # preimage=0000000000000000000000000000000000000000000000000000000000000000 + payment_hash=66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000F4240000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd6b6fd853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b1450d92edf1300d7cfd2ffa175ab1c551817d67b9d095c976faaa23e598ba243 + + 2. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd + htlc_signature=1d64a13cb4aa4edcf5fee860dde77dd0cdd2742d5f87fc0c35a3c00cc9b3f27e56e658e809103ee2426a3710fc83139408bf99020d5c91f478cf386ef2d48931 + + 3. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + + 4. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a + htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + + 5. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a + next_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad + +# Either way, it should reject HTLC, as it's not a known preimage. +12. expect-send: type=update_fail_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + # FIXME: check that reason is correct! + +13. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 + htlc_signature= + +14. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 + # per_commitment_secret #3=ba65d7b0ef55a3ba300d4e87af29868f394f8f138d78a7011669c79b37b936f4 + next_per_commitment_point=030f1b0e7b158de0d85a05ec050304dcf189c879a888e5ca1ce45e829d4b075d37 + +15. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 + htlc_signature= + +16. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 + # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 + next_per_commitment_point=02d8489d0db616cbdfc77d5eadd56c1bc8f136b8fb6b184167ff5cc7fceed71977 From 04eb8e34630854e17043785c908303f9ad50d8e3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:28 +0930 Subject: [PATCH 042/103] tests: add reconnection tests to add-htlc. Signed-off-by: Rusty Russell --- tests/events/bolt2-02-add-htlc.events | 459 +++++++++++++++++++++++++- 1 file changed, 449 insertions(+), 10 deletions(-) diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index 289c0da84..bd24a863e 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -1,5 +1,17 @@ # Variations on open_channel. +# BOLT #7: +# The origin node: +# - MAY create a `channel_update` to communicate the channel +# parameters to the channel peer, even though the channel has not +# yet been announced (i.e. the `announce_channel` bit was not set). + +# In fact, it makes sense to do this after each reconnect. +MAYBE_UPDATE=maybe-send: type=channel_update + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + # FIXME: Fill other expected fields here! + 1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 2. expect-send: type=init 3. recv: type=init globalfeatures= localfeatures=02 @@ -74,10 +86,40 @@ # per_commitment_secret #1 = dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d -11. maybe-send: type=channel_update - chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f - short_channel_id=103x1x0 - # FIXME: Fill other expected fields here! +11. $MAYBE_UPDATE + + # Optional reconnection testing. + 1. nothing + + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 7. $MAYBE_UPDATE + # BOLT #2: + # - if `next_commitment_number` is 1 in both the + # `channel_reestablish` it sent and received: + # - MUST retransmit `funding_locked`. + # - otherwise: + # - MUST NOT retransmit `funding_locked`. + 8. expect-send: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + +# That aside has nothing to do with the next aside. +12. nothing # Add a dust HTLC 1. recv: type=update_add_htlc @@ -89,12 +131,45 @@ cltv_expiry=200 # hop_data[0] = 00000000000000000000000000000003E8000000C8000000000000000000000000 onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd9f755853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b3113cbed88e6cfb566f7a693bb63c9a89925c1f5df0a115b4893128866a81c1b + + # Optional reconnection testing. + 1. nothing + + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 7. $MAYBE_UPDATE + 8. expect-send: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + 9. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + amount_msat=1000 + # preimage=0000000000000000000000000000000000000000000000000000000000000000 + payment_hash=66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000003E8000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd9f755853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b3113cbed88e6cfb566f7a693bb63c9a89925c1f5df0a115b4893128866a81c1b 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c htlc_signature= - + 3. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc @@ -106,12 +181,108 @@ signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 htlc_signature= + # Optional reconnection testing. + 1. nothing + + # If tester did not receive node's revoke_and_ack: + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 7. $MAYBE_UPDATE + # - MUST re-send the `revoke_and_ack`. + 8. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + 9. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + htlc_signature= + + # If tester did receive node's revoke_and_ack, but not commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 7. $MAYBE_UPDATE + 8. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + htlc_signature= + + # If tester did receive node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + 5. recv: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a next_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad + # Optional reconnection testing. + 1. nothing + + # tester must have received node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + # Add a non-dust HTLC 1. recv: type=update_add_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -123,6 +294,39 @@ # hop_data[0] = 00000000000000000000000000000F4240000000C8000000000000000000000000 onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd6b6fd853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b1450d92edf1300d7cfd2ffa175ab1c551817d67b9d095c976faaa23e598ba243 + # Optional reconnection testing. + 1. nothing + + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 7. $MAYBE_UPDATE + 8. expect-send: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + 9. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + amount_msat=1000000 + # preimage=0000000000000000000000000000000000000000000000000000000000000000 + payment_hash=66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000F4240000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd6b6fd853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b1450d92edf1300d7cfd2ffa175ab1c551817d67b9d095c976faaa23e598ba243 + 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd @@ -139,36 +343,271 @@ signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + # Optional reconnection testing. + 1. nothing + + # If tester did not receive node's revoke_and_ack: + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 7. $MAYBE_UPDATE + # - MUST re-send the `revoke_and_ack`. + 8. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + 9. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a + htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + + # If tester did receive node's revoke_and_ack, but not commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 7. $MAYBE_UPDATE + 8. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a + htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + + # If tester did receive node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + 5. recv: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a next_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad + # Optional reconnection testing. + 1. nothing + + # tester must have received node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + # Either way, it should reject HTLC, as it's not a known preimage. -12. expect-send: type=update_fail_htlc +13. expect-send: type=update_fail_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 # FIXME: check that reason is correct! -13. expect-send: type=commitment_signed + # Optional reconnection testing. + 1. nothing + + # tester must have received node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + # Now it will re-transmit + 8. expect-send: type=update_fail_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + +14. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 htlc_signature= -14. recv: type=revoke_and_ack + # Optional reconnection testing. + 1. nothing + + # tester has not received last commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + # Now it will re-transmit + 8. expect-send: type=update_fail_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + 9. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 + htlc_signature= + + # tester *has* received last commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE + +15. recv: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 # per_commitment_secret #3=ba65d7b0ef55a3ba300d4e87af29868f394f8f138d78a7011669c79b37b936f4 next_per_commitment_point=030f1b0e7b158de0d85a05ec050304dcf189c879a888e5ca1ce45e829d4b075d37 -15. recv: type=commitment_signed + # Optional reconnection testing. + 1. nothing + + # tester must have received last commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=2 + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE + +16. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 htlc_signature= -16. expect-send: type=revoke_and_ack +17. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 next_per_commitment_point=02d8489d0db616cbdfc77d5eadd56c1bc8f136b8fb6b184167ff5cc7fceed71977 + + # Optional reconnection testing. + 1. nothing + + # tester *has not* received revoke_and_ack + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE + + # tester *has* received revoke_and_ack + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE + From d67cf5a335e25de82289ac5a73d14b126942bd35 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:28 +0930 Subject: [PATCH 043/103] tests: htlc success tests. Signed-off-by: Rusty Russell --- tests/events/bolt2-03-htlc-fulfill.events | 371 ++++++++++++++++++++++ 1 file changed, 371 insertions(+) create mode 100644 tests/events/bolt2-03-htlc-fulfill.events diff --git a/tests/events/bolt2-03-htlc-fulfill.events b/tests/events/bolt2-03-htlc-fulfill.events new file mode 100644 index 000000000..03392fa8e --- /dev/null +++ b/tests/events/bolt2-03-htlc-fulfill.events @@ -0,0 +1,371 @@ +# Variations on open_channel. + +# BOLT #7: +# The origin node: +# - MAY create a `channel_update` to communicate the channel +# parameters to the channel peer, even though the channel has not +# yet been announced (i.e. the `announce_channel` bit was not set). + +# In fact, it makes sense to do this after each reconnect. +MAYBE_UPDATE=maybe-send: type=channel_update + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + # FIXME: Fill other expected fields here! + +# Make two invoices: one is dust, one is not. +1. invoice: amount=1000 preimage=0000000000000000000000000000000000000000000000000000000000001000 +2. invoice: amount=1000000 preimage=0000000000000000000000000000000000000000000000000000000001000000 + +3. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +4. expect-send: type=init +5. recv: type=init globalfeatures= localfeatures=02 +6. recv: type=open_channel + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + funding_satoshis=999878 + push_msat=0 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=4294967295 + channel_reserve_satoshis=9998 + htlc_minimum_msat=0 + feerate_per_kw=253 + to_self_delay=6 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 + funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000021 + revocation_basepoint=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000022 + payment_basepoint=031be68a5a028f2601d0e80d468c344ba331d611b96c358b6032e8b4da0547fc11 + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000023 + delayed_payment_basepoint=03605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479 + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000024 + htlc_basepoint=02e0392cfa338aaf2f0b56c563e3e5e67a5d5fefe3388f85d90c899da20f0198f9 + # shachain seed=0000000000000000000000000000000000000000000000000000000000000000 + # first per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 + channel_flags=01 + +7. expect-send: type=accept_channel + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 + funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000011 + revocation_basepoint=03defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000012 + payment_basepoint=025601570cb47f238d2b0286db4a990fa0f3ba28d1a319f5e7cf55c2a2444da7cc + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000013 + delayed_payment_basepoint=022b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000014 + htlc_basepoint=024ce119c96e2fa357200b559b2f7dd5a5f02d5290aff74b03f3e471b273211c97 + # shachain seed=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + # per_commitment_secret #0=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + first_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 + # If these are different, the commitment tx will be different! + to_self_delay=6 + channel_reserve_satoshis=9998 + +8. recv: type=funding_created + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f + funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + funding_output_index=0 + # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 + signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + +9. expect-send: type=funding_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 + signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + +10. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + +11. expect-send: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + +12. recv: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # per_commitment_secret #1 = dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 + next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d + +13. $MAYBE_UPDATE + +# First invoice-paying HTLC +14. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + amount_msat=1000 + # preimage=0000000000000000000000000000000000000000000000000000000000001000 + payment_hash=0193d8ff39177fc604d8c0e60d5495222da10cd84d4ae6d12bf84ca923158b31 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000003E8000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd9f755853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941ba2804c6057dd454fbb44ad5e52b3383b9bcfda3647eefe650ab93b99ee60c8da + +15. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=1 + amount_msat=1000000 + # preimage=0000000000000000000000000000000000000000000000000000000001000000 + payment_hash=954a6575b642bdddd05409cf5973ba837f25b2e391950be91fa23334093d88f5 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000F4240000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd6b6fd853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b5be6403eef1373ff72577187afc526cac3c467f07dd00cc91886109c914781d7 + +16. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=bc5e1b465773cfe59478c5db35e9f9d27bf832436d0ed0c19833b5e7d444e9f26e3522883a110d71e715471727e3ea7703eba0e6e9855e8d59bc0bf93029bb29 + htlc_signature=cb0e7a9b30062bed56360797083350883f2a5a7626e510027b83f5d0989f109841c01fcc1eb72a561737eabdb2f1aa1a3b3894181771aa8b749553bf9bb6569c + +17. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + +18. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=64ce07df4f7d4e3e2a29ae6c78baf1d5087a5028f08f537eaed25a5fd1a1f73836d592ff80ba34bbd8f26a0fee17bc8a1fda64006fa4d28f9d52936e17d0abcb + htlc_signature=cfc5c03c510835df5d113b9da9ecdd1b73a602e5bd5a0703c9e53e863da3d8b1193c44913bdc856623f6a706a86256b4939115dec12a79c1f2585cfe7e91a472 + + # Optional reconnection testing. + 1. nothing + + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + + # If tester did not receive node's revoke_and_ack: + 1. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=0 + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 2. $MAYBE_UPDATE + # - MUST re-send the `revoke_and_ack` and `commitment_signed` + 3. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + 4. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=64ce07df4f7d4e3e2a29ae6c78baf1d5087a5028f08f537eaed25a5fd1a1f73836d592ff80ba34bbd8f26a0fee17bc8a1fda64006fa4d28f9d52936e17d0abcb + htlc_signature=cfc5c03c510835df5d113b9da9ecdd1b73a602e5bd5a0703c9e53e863da3d8b1193c44913bdc856623f6a706a86256b4939115dec12a79c1f2585cfe7e91a472 + + # If tester did receive node's revoke_and_ack, but not commitment_signed + 1. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=1 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + 2. $MAYBE_UPDATE + # - MUST re-send `commitment_signed` + 3. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=64ce07df4f7d4e3e2a29ae6c78baf1d5087a5028f08f537eaed25a5fd1a1f73836d592ff80ba34bbd8f26a0fee17bc8a1fda64006fa4d28f9d52936e17d0abcb + htlc_signature=cfc5c03c510835df5d113b9da9ecdd1b73a602e5bd5a0703c9e53e863da3d8b1193c44913bdc856623f6a706a86256b4939115dec12a79c1f2585cfe7e91a472 + + # If tester did receive node's commitment_signed + 1. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 2. $MAYBE_UPDATE + +19. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a + next_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad + +# It should accept both of them, but could be in any order. +# (Could also do this in two separate commits, but I didn't add that). +20. One of: + 1. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 + 2. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=1 + payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 + + 1. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=1 + payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 + 2. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 + +# Separator: next is not part of One Of. +21. nothing + + # Optional reconnection testing. + 1. nothing + + # tester must have received node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + # Now it will re-transmit + 8. One of: + 1. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 + 2. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=1 + payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 + + 1. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=1 + payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 + 2. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 + +22. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 + htlc_signature= + + # Optional reconnection testing. + 1. nothing + + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + + # tester has not received last commitment_signed + 1. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 2. $MAYBE_UPDATE + # Now it will re-transmit + 3. One of: + 1. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 + 2. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=1 + payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 + + 1. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=1 + payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 + 2. expect-send: type=update_fulfill_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 + 4. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 + htlc_signature= + + # tester *has* received last commitment_signed + 1. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 2. $MAYBE_UPDATE + +23. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 + # per_commitment_secret #3=ba65d7b0ef55a3ba300d4e87af29868f394f8f138d78a7011669c79b37b936f4 + next_per_commitment_point=030f1b0e7b158de0d85a05ec050304dcf189c879a888e5ca1ce45e829d4b075d37 + +24. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=cf1292877b98697abbb2af4a28e7cba5dfeaa3e259ce528248881befa0e9008f6c8d2d1086266abb3bef002aa0fff652ed1d4f3bc60c8e5a22fbb3a3b584c47f + htlc_signature= + +25. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 + # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 + next_per_commitment_point=02d8489d0db616cbdfc77d5eadd56c1bc8f136b8fb6b184167ff5cc7fceed71977 + + # Optional reconnection testing. + 1. nothing + + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + + # tester *has not* received revoke_and_ack + 1. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 2. $MAYBE_UPDATE + 3. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 + # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 + next_per_commitment_point=02d8489d0db616cbdfc77d5eadd56c1bc8f136b8fb6b184167ff5cc7fceed71977 + + # tester *has* received revoke_and_ack + 1. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 2. $MAYBE_UPDATE From 73a04e76eec757d6040f953e553701da3df756f0 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:28 +0930 Subject: [PATCH 044/103] tests: make to_self_delay different between peers. This helps for testing that we handle it correctly. Signed-off-by: Rusty Russell --- tests/events/bolt2-02-add-htlc.events | 5 +++-- tests/events/bolt2-03-htlc-fulfill.events | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index bd24a863e..c681618d8 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -25,7 +25,8 @@ MAYBE_UPDATE=maybe-send: type=channel_update channel_reserve_satoshis=9998 htlc_minimum_msat=0 feerate_per_kw=253 - to_self_delay=6 + # node has to_self_delay=6; we use 5 to test differentiation + to_self_delay=5 max_accepted_htlcs=483 # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 @@ -330,7 +331,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd - htlc_signature=1d64a13cb4aa4edcf5fee860dde77dd0cdd2742d5f87fc0c35a3c00cc9b3f27e56e658e809103ee2426a3710fc83139408bf99020d5c91f478cf386ef2d48931 + htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 3. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 diff --git a/tests/events/bolt2-03-htlc-fulfill.events b/tests/events/bolt2-03-htlc-fulfill.events index 03392fa8e..e4fb3bded 100644 --- a/tests/events/bolt2-03-htlc-fulfill.events +++ b/tests/events/bolt2-03-htlc-fulfill.events @@ -29,7 +29,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update channel_reserve_satoshis=9998 htlc_minimum_msat=0 feerate_per_kw=253 - to_self_delay=6 + to_self_delay=5 max_accepted_htlcs=483 # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 @@ -116,7 +116,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update 16. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=bc5e1b465773cfe59478c5db35e9f9d27bf832436d0ed0c19833b5e7d444e9f26e3522883a110d71e715471727e3ea7703eba0e6e9855e8d59bc0bf93029bb29 - htlc_signature=cb0e7a9b30062bed56360797083350883f2a5a7626e510027b83f5d0989f109841c01fcc1eb72a561737eabdb2f1aa1a3b3894181771aa8b749553bf9bb6569c + htlc_signature=8ef6bc3d35a91a00cd1edb0a22e5ca7204b297d41cd7c4cdb1c4167d2d298d907e23b9dc75356ff2fee9ced4abc9fba796a90a2939df45080d12c7bbadbda8d8 17. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -324,7 +324,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update 24. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=cf1292877b98697abbb2af4a28e7cba5dfeaa3e259ce528248881befa0e9008f6c8d2d1086266abb3bef002aa0fff652ed1d4f3bc60c8e5a22fbb3a3b584c47f + signature=85aebf2874c464db7eac10e0bad98b491c9ac943eae263bb4396d4e5feded12f1284e26196397313be31f4e83334eb5a6641cbec158e0fbfb22c4c488b3a28fd htlc_signature= 25. expect-send: type=revoke_and_ack From 8684b8b6ad1e1cf56c9c78b46ec3b52ecd773db9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:28 +0930 Subject: [PATCH 045/103] tests/events: split htlc-add and htlc-fail tests. Signed-off-by: Rusty Russell --- tests/events/bolt2-02-add-htlc.events | 169 +------- tests/events/bolt2-03-htlc-fail.events | 366 ++++++++++++++++++ ...ll.events => bolt2-04-htlc-fulfill.events} | 2 +- 3 files changed, 368 insertions(+), 169 deletions(-) create mode 100644 tests/events/bolt2-03-htlc-fail.events rename tests/events/{bolt2-03-htlc-fulfill.events => bolt2-04-htlc-fulfill.events} (99%) diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index c681618d8..0e40fc42b 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -1,4 +1,4 @@ -# Variations on open_channel. +# Variations on adding an HTLC. # BOLT #7: # The origin node: @@ -445,170 +445,3 @@ MAYBE_UPDATE=maybe-send: type=channel_update your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect 7. $MAYBE_UPDATE - -# Either way, it should reject HTLC, as it's not a known preimage. -13. expect-send: type=update_fail_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=0 - # FIXME: check that reason is correct! - - # Optional reconnection testing. - 1. nothing - - # tester must have received node's commitment_signed - 1. disconnect: - 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 - 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 - 5. expect-send: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=2 - next_revocation_number=1 - your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect - 6. recv: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=2 - next_revocation_number=1 - your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect - 7. $MAYBE_UPDATE - # Now it will re-transmit - 8. expect-send: type=update_fail_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=0 - -14. expect-send: type=commitment_signed - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 - htlc_signature= - - # Optional reconnection testing. - 1. nothing - - # tester has not received last commitment_signed - 1. disconnect: - 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 - 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 - 5. expect-send: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=2 - next_revocation_number=1 - your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect - 6. recv: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=2 - next_revocation_number=1 - your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect - 7. $MAYBE_UPDATE - # Now it will re-transmit - 8. expect-send: type=update_fail_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=0 - 9. expect-send: type=commitment_signed - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 - htlc_signature= - - # tester *has* received last commitment_signed - 1. disconnect: - 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 - 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 - 5. expect-send: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=2 - next_revocation_number=1 - your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect - 6. recv: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=3 - next_revocation_number=1 - your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect - 7. $MAYBE_UPDATE - -15. recv: type=revoke_and_ack - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 - # per_commitment_secret #3=ba65d7b0ef55a3ba300d4e87af29868f394f8f138d78a7011669c79b37b936f4 - next_per_commitment_point=030f1b0e7b158de0d85a05ec050304dcf189c879a888e5ca1ce45e829d4b075d37 - - # Optional reconnection testing. - 1. nothing - - # tester must have received last commitment_signed - 1. disconnect: - 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 - 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 - 5. expect-send: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=2 - next_revocation_number=2 - your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect - 6. recv: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=3 - next_revocation_number=1 - your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect - 7. $MAYBE_UPDATE - -16. recv: type=commitment_signed - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 - htlc_signature= - -17. expect-send: type=revoke_and_ack - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 - # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 - next_per_commitment_point=02d8489d0db616cbdfc77d5eadd56c1bc8f136b8fb6b184167ff5cc7fceed71977 - - # Optional reconnection testing. - 1. nothing - - # tester *has not* received revoke_and_ack - 1. disconnect: - 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 - 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 - 5. expect-send: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=3 - next_revocation_number=2 - your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect - my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect - 6. recv: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=3 - next_revocation_number=1 - your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect - 7. $MAYBE_UPDATE - - # tester *has* received revoke_and_ack - 1. disconnect: - 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 - 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 - 5. expect-send: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=3 - next_revocation_number=2 - your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect - my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect - 6. recv: type=channel_reestablish - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - next_commitment_number=3 - next_revocation_number=2 - your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect - 7. $MAYBE_UPDATE - diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events new file mode 100644 index 000000000..882502855 --- /dev/null +++ b/tests/events/bolt2-03-htlc-fail.events @@ -0,0 +1,366 @@ +# Variations on HTLC failure. + +# BOLT #7: +# The origin node: +# - MAY create a `channel_update` to communicate the channel +# parameters to the channel peer, even though the channel has not +# yet been announced (i.e. the `announce_channel` bit was not set). + +# In fact, it makes sense to do this after each reconnect. +MAYBE_UPDATE=maybe-send: type=channel_update + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + # FIXME: Fill other expected fields here! + +1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +2. expect-send: type=init +3. recv: type=init globalfeatures= localfeatures=02 +4. recv: type=open_channel + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + funding_satoshis=999878 + push_msat=0 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=4294967295 + channel_reserve_satoshis=9998 + htlc_minimum_msat=0 + feerate_per_kw=253 + # node has to_self_delay=6; we use 5 to test differentiation + to_self_delay=5 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 + funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000021 + revocation_basepoint=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000022 + payment_basepoint=031be68a5a028f2601d0e80d468c344ba331d611b96c358b6032e8b4da0547fc11 + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000023 + delayed_payment_basepoint=03605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479 + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000024 + htlc_basepoint=02e0392cfa338aaf2f0b56c563e3e5e67a5d5fefe3388f85d90c899da20f0198f9 + # shachain seed=0000000000000000000000000000000000000000000000000000000000000000 + # first per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 + channel_flags=01 + +5. expect-send: type=accept_channel + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 + funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000011 + revocation_basepoint=03defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000012 + payment_basepoint=025601570cb47f238d2b0286db4a990fa0f3ba28d1a319f5e7cf55c2a2444da7cc + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000013 + delayed_payment_basepoint=022b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000014 + htlc_basepoint=024ce119c96e2fa357200b559b2f7dd5a5f02d5290aff74b03f3e471b273211c97 + # shachain seed=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + # per_commitment_secret #0=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + first_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 + # If these are different, the commitment tx will be different! + to_self_delay=6 + channel_reserve_satoshis=9998 + +6. recv: type=funding_created + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f + funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + funding_output_index=0 + # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 + signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + +7. expect-send: type=funding_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 + signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + +8. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + +9. expect-send: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + +10. recv: type=funding_locked + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # per_commitment_secret #1 = dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 + next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d + +11. $MAYBE_UPDATE + + # Add a dust HTLC + 1. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + amount_msat=1000 + # preimage=0000000000000000000000000000000000000000000000000000000000000000 + payment_hash=66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000003E8000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd9f755853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b3113cbed88e6cfb566f7a693bb63c9a89925c1f5df0a115b4893128866a81c1b + + 2. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c + htlc_signature= + + 3. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + + 4. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + htlc_signature= + + 5. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a + next_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad + + # Optional reconnection testing. + 1. nothing + + # tester must have received node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + + # Add a non-dust HTLC + 1. recv: type=update_add_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + amount_msat=1000000 + # preimage=0000000000000000000000000000000000000000000000000000000000000000 + payment_hash=66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925 + cltv_expiry=200 + # hop_data[0] = 00000000000000000000000000000F4240000000C8000000000000000000000000 + onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd6b6fd853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b1450d92edf1300d7cfd2ffa175ab1c551817d67b9d095c976faaa23e598ba243 + + 2. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd + htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 + + 3. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 + next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad + + 4. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a + htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + + 5. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a + next_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad + + # Optional reconnection testing. + 1. nothing + + # tester must have received node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + +# Either way, it should reject HTLC, as it's not a known preimage. +12. expect-send: type=update_fail_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + # FIXME: check that reason is correct! + + # Optional reconnection testing. + 1. nothing + + # tester must have received node's commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + # Now it will re-transmit + 8. expect-send: type=update_fail_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + +13. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 + htlc_signature= + + # Optional reconnection testing. + 1. nothing + + # tester has not received last commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + 7. $MAYBE_UPDATE + # Now it will re-transmit + 8. expect-send: type=update_fail_htlc + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + id=0 + 9. expect-send: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 + htlc_signature= + + # tester *has* received last commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=1 + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE + +14. recv: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 + # per_commitment_secret #3=ba65d7b0ef55a3ba300d4e87af29868f394f8f138d78a7011669c79b37b936f4 + next_per_commitment_point=030f1b0e7b158de0d85a05ec050304dcf189c879a888e5ca1ce45e829d4b075d37 + + # Optional reconnection testing. + 1. nothing + + # tester must have received last commitment_signed + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=2 + next_revocation_number=2 + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE + +15. recv: type=commitment_signed + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 + htlc_signature= + +16. expect-send: type=revoke_and_ack + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 + # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 + next_per_commitment_point=02d8489d0db616cbdfc77d5eadd56c1bc8f136b8fb6b184167ff5cc7fceed71977 + + # Optional reconnection testing. + 1. nothing + + # tester *has not* received revoke_and_ack + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=1 + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE + + # tester *has* received revoke_and_ack + 1. disconnect: + 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 + 3. expect-send: type=init + 4. recv: type=init globalfeatures= localfeatures=02 + 5. expect-send: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + 6. recv: type=channel_reestablish + channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + next_commitment_number=3 + next_revocation_number=2 + your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + 7. $MAYBE_UPDATE diff --git a/tests/events/bolt2-03-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events similarity index 99% rename from tests/events/bolt2-03-htlc-fulfill.events rename to tests/events/bolt2-04-htlc-fulfill.events index e4fb3bded..1ab615043 100644 --- a/tests/events/bolt2-03-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -1,4 +1,4 @@ -# Variations on open_channel. +# Variations on HTLC success. # BOLT #7: # The origin node: From abb41ed302847a4e11de3ac014f58a0f0020d216 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Aug 2019 20:07:28 +0930 Subject: [PATCH 046/103] tests/events: test unknown messages. Signed-off-by: Rusty Russell --- tests/events/bolt1-02-unknown-messages.events | 22 +++++++++++++++++++ tests/events/bolt2-01-open_channel.events | 13 +++++++++++ tests/events/bolt2-02-add-htlc.events | 21 ++++++++++++++++++ tests/events/bolt2-03-htlc-fail.events | 12 ++++++++++ tests/events/bolt2-04-htlc-fulfill.events | 12 ++++++++++ 5 files changed, 80 insertions(+) create mode 100644 tests/events/bolt1-02-unknown-messages.events diff --git a/tests/events/bolt1-02-unknown-messages.events b/tests/events/bolt1-02-unknown-messages.events new file mode 100644 index 000000000..ab5949416 --- /dev/null +++ b/tests/events/bolt1-02-unknown-messages.events @@ -0,0 +1,22 @@ +# Init exchange, with unknown messages +# +# BOLT #1: +# The receiving node: +#... +# - upon receiving unknown _odd_ feature bits that are non-zero: +# - MUST ignore the bit. +# - upon receiving unknown _even_ feature bits that are non-zero: +# - MUST fail the connection. + +1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 +2. expect-send: type=init conn=0000000000000000000000000000000000000000000000000000000000000003 +3. recv: type=init globalfeatures= localfeatures= + + 1. nothing + + # Unknown odd is OK. + 1. recv: type=9999 + + # Unknown even causes error. + 1. recv: type=10000 + 2. expect-error: diff --git a/tests/events/bolt2-01-open_channel.events b/tests/events/bolt2-01-open_channel.events index 7083f26c8..e3a6f7311 100644 --- a/tests/events/bolt2-01-open_channel.events +++ b/tests/events/bolt2-01-open_channel.events @@ -33,6 +33,10 @@ first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 channel_flags=01 + # Ignore unknown odd messages + 1. nothing + 1. recv: type=9999 + 2. expect-send: type=accept_channel temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 @@ -53,6 +57,10 @@ to_self_delay=6 channel_reserve_satoshis=9998 + # Ignore unknown messages + 1. nothing + 1. recv: type=9999 + 3. recv: type=funding_created temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 @@ -76,3 +84,8 @@ 7. recv: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d + + # Ignore unknown odd messages + 1. nothing + 1. recv: type=9999 + diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index 0e40fc42b..0a16dd899 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -92,6 +92,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init @@ -136,6 +139,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init @@ -185,6 +191,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # If tester did not receive node's revoke_and_ack: 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 @@ -265,6 +274,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # tester must have received node's commitment_signed 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 @@ -298,6 +310,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init @@ -347,6 +362,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # If tester did not receive node's revoke_and_ack: 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 @@ -427,6 +445,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # tester must have received node's commitment_signed 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events index 882502855..973d1a357 100644 --- a/tests/events/bolt2-03-htlc-fail.events +++ b/tests/events/bolt2-03-htlc-fail.events @@ -208,6 +208,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # tester must have received node's commitment_signed 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 @@ -239,6 +242,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # tester has not received last commitment_signed 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 @@ -294,6 +300,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # tester must have received last commitment_signed 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 @@ -327,6 +336,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # tester *has not* received revoke_and_ack 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index 1ab615043..c092e9e00 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -132,6 +132,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init @@ -218,6 +221,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + # tester must have received node's commitment_signed 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 @@ -264,6 +270,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init @@ -336,6 +345,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update # Optional reconnection testing. 1. nothing + # Ignore unknown odd messages + 1. recv: type=9999 + 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init From b6bfb478df439a6d4048864ea2a4486f9f8be857 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Mon, 12 Aug 2019 10:20:10 +0930 Subject: [PATCH 047/103] fixup: unpack handle TLV fields --- tools/test-events.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/test-events.py b/tools/test-events.py index 893c1d34b..8ca95b887 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -131,6 +131,10 @@ def unpack_from(typename, bytestream, offset): struct.unpack_from(name2structfmt[typename], bytestream, offset)[0]) + # FIXME: This is our non-TLV code + if typename.endswith('_tlvs'): + return len(bytestream) - offset, bytestream[offset:] + # Unpack directly as bytes size = name2size[typename] if size + offset > len(bytestream): From d250ebe830c4770ddf0c82da07d3af407ff14ebf Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Mon, 12 Aug 2019 10:20:17 +0930 Subject: [PATCH 048/103] rfc-tests: handle subtype parsing Preliminary parsing for subtypes. Probably need something on the unpacking side also. --- tools/test-events.py | 139 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 5 deletions(-) diff --git a/tools/test-events.py b/tools/test-events.py index 8ca95b887..45e866930 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -116,6 +116,13 @@ def pack(typename, v): if typename in name2structfmt: return struct.pack(name2structfmt[typename], v) + # FIXME: This is our non-TLV code + if typename.endswith('_tlvs'): + return v + + if typename in Subtype.objs: + return Subtype.objs[typename].pack(v) + # Pack directly as bytes assert len(v) == name2size[typename] return bytes(v) @@ -297,6 +304,9 @@ def field_value(self, line, value): "{} byte array should be length {} not {}" .format(self.name, self.arraylen, len(v))) return v, len(v) + elif self.typename in Subtype.objs: # Subtypes + subtype = Subtype.objs[self.typename] + return subtype.parse(line, value) else: arr = [] # Empty string doesn't quite do what we want with split. @@ -372,6 +382,117 @@ def find_message(messages, name): return None +class Subtype(Message): + objs = {} + + def __init__(self, name): + Message.__init__(self, name, '0') + + def parse(self, line, s): + """ Given an input line for a subtype, parse it into a dict + of fields for that subtype """ + if len(s) == 0: + return b'', 0 + + if s[0] == '[': + i = 1 + arr = [] + while i < len(s) and s[i] != ']': + end, obj = self._parse_obj(line, s[i:]) + arr.append(obj) + i += end + if i < len(s) and s[i] == ',': + i += 1 + return arr, len(arr) + else: + return self._parse_obj(line, s), None + + def _parse_obj(self, line, s): + if s[0] != '{': + raise LineError(line, "Subtype formatted incorrectly. got {} when expecting an open bracket ({},{})" + .format(s[0], self.name, s)) + + end, fields = self.find_fields(s) + if end < 0: + raise LineError(line, "Subtype formatted incorrectly. No end bracket found ({}, {})" + .format(self.name, s)) + + val = {} + for f_name, f_val in fields: + sub_field = self.findField(f_name) + + if not sub_field: + raise LineError(line, "{} subtype error. Unable to find field {}" + .format(self.name, f_name)) + + val[f_name], vararrlen = sub_field.field_value(line, f_val) + if vararrlen is not None: + val[sub_field.arrayvar.name] = vararrlen + + return end + 1, val + + def find_fields(self, s): + """ Handle nested arrays + objects. Returns set of fields for + the upper most object and the 'end' count of where this object ends. + {abc=[{},{}],bcd=[{},{}],...],abc=[]},{abc=[{},{}]}... """ + arr_count = 0 + bracket_count = 0 + end = len(s) + field_set = [] + i = 0 + field = '' + tok = None + while i < end: + if s[i] == '[': + arr_count += 1 + field += s[i] + elif s[i] == ']': + arr_count -= 1 + field += s[i] + elif s[i] == '{': + bracket_count += 1 + if i != 0: + field += s[i] + elif s[i] == '}': + bracket_count -= 1 + if bracket_count == 0: + field_set.append((tok, field)) + return i, field_set + else: + field += s[i] + elif s[i] == ',': + if bracket_count == 1 and arr_count == 0: + field_set.append((tok, field)) + field = '' + tok = None + else: + field += s[i] + elif s[i] == '=': + if not tok: + tok = field + field = '' + else: + field += s[i] + else: + field += s[i] + + i += 1 + return -1, None + + + def pack(self, values): + """ We need to return bytes for each field """ + bites = bytes([]) + for f in self.fields: + if f.name in values: + val = values[f.name] + if f.arrayvar or f.arraylen: + for a in val: + bites += pack(f.typename, a) + else: + bites += pack(f.typename, val) + return bites + def read_csv(args): for line in fileinput.input(args.csv_file): @@ -383,11 +504,19 @@ def read_csv(args): elif parts[0] == 'msgdata': m = find_message(messages, parts[1]) if m is None: - raise ValueError('Unknown message {}'.format(parts[0])) + raise ValueError('Unknown message {}'.format(parts[1])) # eg. msgdata,channel_reestablish,your_last_per_commitment_secret # ,secret,,1option209 m.addField(Field(m, parts[2], parts[3], parts[4], parts[5:])) + elif parts[0] == 'subtype': + Subtype.objs[parts[1]] = Subtype(parts[1]) + elif parts[0] == 'subtypedata': + if parts[1] not in Subtype.objs: + raise ValueError('Unknown subtype {}'.format(parts[1])) + # Insert fields into dict for subtype + subtype = Subtype.objs[parts[1]] + subtype.addField(Field(subtype, parts[2], parts[3], parts[4], parts[5:])) def parse_params(line, parts, compulsorykeys, optionalkeys=[]): @@ -450,7 +579,7 @@ def which_connection(line, runner, connkey): return c raise LineError(line, "No active 'connect' {}".format(connkey)) - + class NothingEvent(object): def __init__(self, line, parts): parse_params(line, parts, []) @@ -730,7 +859,7 @@ def action(self, runner, line): msg = runner.expect_send(conn, line) else: break - + if conn.maybe_sends != []: raise ValidationError(line, failreason @@ -899,7 +1028,7 @@ def __str__(self): def __repr__(self): return "Sequence:{}".format(self) - + def run(self, runner, start=0): if self.args.verbose: print("# running {}:".format(self)) @@ -980,7 +1109,7 @@ def load_sequence(args, lines, linenum, indentlevel, graph): seq = init_seq terminals = [seq] - + if graph is not None: graph.add_node(seq) From 97eb45ae0d593434f428976fd8fb01bcf3037d79 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Mon, 12 Aug 2019 10:20:22 +0930 Subject: [PATCH 049/103] WIP: handle unpack subtypes --- tools/test-events.py | 211 +++++++++++++++++++++++++++---------------- 1 file changed, 134 insertions(+), 77 deletions(-) diff --git a/tools/test-events.py b/tools/test-events.py index 45e866930..17b8208ae 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -142,6 +142,10 @@ def unpack_from(typename, bytestream, offset): if typename.endswith('_tlvs'): return len(bytestream) - offset, bytestream[offset:] + if typename in Subtype.objs: + subtype = Subtype.objs[typename] + return subtype.unpack(bytestream, offset) + # Unpack directly as bytes size = name2size[typename] if size + offset > len(bytestream): @@ -405,7 +409,8 @@ def parse(self, line, s): i += 1 return arr, len(arr) else: - return self._parse_obj(line, s), None + _, obj = self.parse_obj(line, s) + return obj, None def _parse_obj(self, line, s): if s[0] != '{': @@ -493,6 +498,81 @@ def pack(self, values): bites += pack(f.typename, val) return bites + def unpack(self, bytestream, offset): + """ For every field, unpack it""" + net_size = 0 + result = {} + lenfields = {} + for f in self.fields: + off, v = unpack_field(f, lenfields, bytestream, offset) + offset += off + net_size += off + result[f.name] = v + + return net_size, result + + def compare(self, msgname, vals, expected): + if not bool(expected): + if bool(vals): + return ("Nothing expected for {}.{} but returned {}" + .format(msgname, self.name, vals)) + return None + for name, exp_val in expected.items(): + if name not in vals: + return ("Expected field {}.{}.{} " + "not present in values" + .format(msgname, self.name, name)) + + f = self.findField(name) + if not f: + return ("Field {} is not known for subtype {}({})" + .format(name, self.name, msgname)) + + val = vals[name] + err = compare_results(msgname + "." + self.name, f, v, exp_val) + if err is not None: + return err + + return None + + +def unpack_field(field, lenfields, bytestream, offset): + # If it's an array, we need the whole thing. + if field.arrayvar or field.arraylen: + if field.arrayvar: + num = lenfields[field.arrayvar.name] + else: + num = field.arraylen + # Array of bytes is special: treat raw. + if field.typename == 'byte': + v = bytestream[offset:offset + num] + offset += num + else: + v = [] + for i in range(0, num): + size, var = unpack_from(field.typename, bytestream, offset) + if size is None: + return ('Response too short to extract {}[{}]: {}' + .format(field.name, i, bytestream.hex())) + offset += size + v += [var] + else: + size, v = unpack_from(field.typename, bytestream, offset) + if size is None: + # Optional fields might not exist + if field.options != []: + v = None + size = 0 + else: + return ('Response too short to extract {}: {}' + .format(field.name, bytestream.hex())) + offset += size + + # If it's used as a length, save it. + if field.islenvar: + lenfields[field.name] = int(v) + + return offset, v def read_csv(args): for line in fileinput.input(args.csv_file): @@ -681,6 +761,53 @@ def action(self, runner, line): runner.recv(which_connection(line, runner, self.connkey), self.b, line) +def compare_results(msgname, f, v, exp): + """ f -> field; v -> value; exp -> expected value """ + + # If they specify field=absent, it must not be there. + if exp is None: + if v is not None: + return "Field {} is present" + else: + return None + + if v is None: + return ("Optional field {} is not present" + .format(f.name)) + if isinstance(exp, tuple): + # Out-of-range bitmaps are considered 0 (eg. feature tests) + if len(v) < len(exp[0]): + cmpv = b'\x00' * (len(exp[0]) - len(v)) + v + elif len(v) > len(exp[0]): + cmpv = v[-len(exp[0]):] + else: + cmpv = v + + for i in range(0, len(exp[0])): + if cmpv[i] & exp[1][i] != exp[0][i]: + return ("Expected {}.{} mask 0x{}" + " value 0x{} but got 0x{}" + " (offset {} different)" + .format(msgname, f.name, + exp[1].hex(), exp[0].hex(), + v.hex(), len(exp[0]) - 1 - i)) + # Use subtype comparer + elif f.typename in Subtype.objs: + return Subtype.objs[f.typename].compare(msgname, v, exp) + + # Simple comparison + elif v != exp: + if f.isinteger: + valstr = str(v) + expectstr = str(exp) + else: + valstr = v.hex() + expectstr = exp.hex() + return ("Expected {}.{} {} but got {}" + .format(msgname, + f.name, expectstr, valstr)) + return None + def message_match(expectmsg, expectfields, b): """Internal helper to see if b matches expectmsg & expectfields. @@ -689,91 +816,21 @@ def message_match(expectmsg, expectfields, b): msgtype = struct.unpack_from(">H", b)[0] off = 2 - # Keep length fields - lenfields = {} if msgtype != expectmsg.value: return "Expected msg {} but got {}: {}".format(expectmsg.name, msgtype, b.hex()) + # Keep length fields + lenfields = {} for f in expectmsg.fields: - # If it's an array, we need the whole thing. - if f.arrayvar or f.arraylen: - if f.arrayvar: - num = lenfields[f.arrayvar.name] - else: - num = f.arraylen - # Array of bytes is special: treat raw. - if f.typename == 'byte': - v = b[off:off + num] - off += num - else: - v = [] - for i in range(0, num): - size, var = unpack_from(f.typename, b, off) - if size is None: - return ('Response too short to extract {}[{}]: {}' - .format(f.name, i, b.hex())) - off += size - v += [var] - else: - size, v = unpack_from(f.typename, b, off) - if size is None: - # Optional fields might not exist - if f.options != []: - v = None - size = 0 - else: - return ('Response too short to extract {}: {}' - .format(f.name, b.hex())) - off += size - - # If it's used as a length, save it. - if f.islenvar: - lenfields[f.name] = int(v) + off, v = unpack_field(f, lenfields, b, off) # They expect a value from this. if f.name in expectfields: exp = expectfields[f.name] + err = compare_results(expectmsg.name, f, v, exp) + if err is not None: + return err + ": {}".format(b.hex()) - # If they specify field=absent, it must not be there. - if exp is None: - if v is not None: - return "Field {} is present" - else: - continue - - if v is None: - return ("Optional field {} is not present in {}" - .format(f.name, b.hex())) - if isinstance(exp, tuple): - # Out-of-range bitmaps are considered 0 (eg. feature tests) - if len(v) < len(exp[0]): - cmpv = b'\x00' * (len(exp[0]) - len(v)) + v - elif len(v) > len(exp[0]): - cmpv = v[-len(exp[0]):] - else: - cmpv = v - - for i in range(0, len(exp[0])): - if cmpv[i] & exp[1][i] != exp[0][i]: - return ("Expected {}.{} mask 0x{}" - " value 0x{} but got 0x{}" - " (offset {} different):" - " {}" - .format(expectmsg.name, f.name, - exp[1].hex(), exp[0].hex(), - v.hex(), len(exp[0]) - 1 - i, - b.hex())) - # Simple comparison - elif v != exp: - if f.isinteger: - valstr = str(v) - expectstr = str(exp) - else: - valstr = v.hex() - expectstr = exp.hex() - return ("Expected {}.{} {} but got {}: {}" - .format(expectmsg.name, - f.name, expectstr, valstr, b.hex())) return None From 20ed1adc74dec202e82222a3ff30514943ae59c9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 15 Aug 2019 16:10:25 +0930 Subject: [PATCH 050/103] Keep flake8 happy. Signed-off-by: Rusty Russell --- tools/test-events-clightning.py | 1 + tools/test-events.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 6b8972c72..7904df360 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -34,6 +34,7 @@ def wait_for(success, timeout=TIMEOUT): interval = 5 return time.time() <= start_time + timeout + # Stolen from lightning/tests/utils.py class SimpleBitcoinProxy: """Wrapper for BitcoinProxy to reconnect. diff --git a/tools/test-events.py b/tools/test-events.py index 17b8208ae..bff4c3877 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -386,6 +386,7 @@ def find_message(messages, name): return None + class Subtype(Message): objs = {} @@ -484,7 +485,6 @@ def find_fields(self, s): i += 1 return -1, None - def pack(self, values): """ We need to return bytes for each field """ bites = bytes([]) @@ -526,10 +526,10 @@ def compare(self, msgname, vals, expected): f = self.findField(name) if not f: return ("Field {} is not known for subtype {}({})" - .format(name, self.name, msgname)) + .format(name, self.name, msgname)) val = vals[name] - err = compare_results(msgname + "." + self.name, f, v, exp_val) + err = compare_results(msgname + "." + self.name, f, val, exp_val) if err is not None: return err @@ -574,6 +574,7 @@ def unpack_field(field, lenfields, bytestream, offset): return offset, v + def read_csv(args): for line in fileinput.input(args.csv_file): parts = line.rstrip().split(',') @@ -640,6 +641,7 @@ def __init__(self, connkey): def __str__(self): return str(self.connkey) + def optional_connection(line, params): """Trivial helper to return & remove conn=key if specified, None if not""" ret = params.pop('conn', None) @@ -761,6 +763,7 @@ def action(self, runner, line): runner.recv(which_connection(line, runner, self.connkey), self.b, line) + def compare_results(msgname, f, v, exp): """ f -> field; v -> value; exp -> expected value """ @@ -1157,6 +1160,7 @@ def act(self, runner): "None of the sequences matched {}" .format(msg.hex())) + # Loads a Sequence at this indent level (and any children embedded in # it, if allow_children). Returns the initial Sequence, a list of # Sequence leaves, and the next linenum. @@ -1307,7 +1311,7 @@ def filter_out(args, line, filename, linenum): def indentation(s): - """Returns str with indent stripped, and effectve indentation amount""" + """Returns str with indent stripped, and effective indentation amount""" level = 0 consumed = 0 for i in range(len(s)): @@ -1318,7 +1322,7 @@ def indentation(s): level = (level + 8) // 8 * 8 else: break - consumed = i+1 + consumed = i + 1 return s[consumed:], level From 06b9ec3462e71a888d07fccad89b443017a7070a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 15 Aug 2019 16:10:32 +0930 Subject: [PATCH 051/103] tests: add must-not-send Useful for gossip tests, antonym of maybe-send. Signed-off-by: Rusty Russell --- tests/events/test-spec.md | 5 +++- tools/test-events-clightning.py | 28 +++++++++++++------- tools/test-events.py | 45 ++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index dc505d2c3..1edd7bb90 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -124,7 +124,7 @@ Input events are: ## Output Events -OUTPUT_EVENT := EXPECT_SEND | MAYBE_SEND | EXPECT_TX | EXPECT_ERROR +OUTPUT_EVENT := EXPECT_SEND | MAYBE_SEND | MUST_NOT_SEND | EXPECT_TX | EXPECT_ERROR EXPECT_SEND := `expect-send:` [CONNSPEC] SPACE+ `type=` TYPENAME SPACE+ SEND_FIELDSPEC* SEND_FIELDSPEC := IDENTIFIER`=`SPECVALUE @@ -132,6 +132,8 @@ SPECVALUE := FIELDVALUE | HEX`/`HEX | `absent` MAYBE_SEND := `maybe-send:` [CONNSPEC] SPACE+ `type=` TYPENAME SEND_FIELDSPEC* +MUST_NOT_SEND := `must-not-send:` [CONNSPEC] SPACE+ `type=` TYPENAME SEND_FIELDSPEC* + EXPECT_TX := `expect-tx:` SPACE+ `tx=`HEX EXPECT_ERROR := `expect-error:` [CONNSPEC] @@ -139,6 +141,7 @@ EXPECT_ERROR := `expect-error:` [CONNSPEC] Output events are: * `expect-send`: a message the implementation is expected to send. Any field specified must match exactly for the test to pass; the value`/`mask notation is used to compare bits against a mask; the field should be zero-padded for comparison if necessary. The special field value `absent` means the (presumably optional) field must not be present. * `maybe-send`: a message the implementation may send, at any point from now on (until the next `disconnect`) +* `must-not-send`: a message the implementation must not send, at any point from now on (until the next `disconnect`). This implies waiting at the end of the test (for a gossip flush!) to make sure it doesn't send it. * `expect-tx`: a transaction the implementation is expected to broadcast. The transactions here assume deterministic signatures. * `expect-error`: the implementation is expected to detect an error. This is generally a `expect-send` of `type=error` but it's legal for it to simply close the connection. If there's no `expect-error` event, the implementation is expected *not* to have an error. diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 7904df360..63026335d 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -136,6 +136,7 @@ def start(self): '--dev-force-bip32-seed=0000000000000000000000000000000000000000000000000000000000000001', '--dev-force-channel-secrets=0000000000000000000000000000000000000000000000000000000000000010/0000000000000000000000000000000000000000000000000000000000000011/0000000000000000000000000000000000000000000000000000000000000012/0000000000000000000000000000000000000000000000000000000000000013/0000000000000000000000000000000000000000000000000000000000000014/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', '--dev-bitcoind-poll=1', + '--dev-broadcast-interval=1000', '--bind-addr=127.0.0.1:{}'.format(self.lightning_port), '--network=regtest', '--bitcoin-rpcuser=rpcuser', @@ -236,21 +237,30 @@ def invoice(self, amount, preimage, line): description='invoice from {}'.format(line), preimage=preimage) + def _readmsg(self, conn): + rawl = conn.proc.stdout.read(2) + length = struct.unpack('>H', rawl)[0] + msg = bytes() + while len(msg) < length: + msg += conn.proc.stdout.read(length - len(msg)) + return msg + def expect_send(self, conn, line, timeout=TIMEOUT): - def readmsg(conn): - rawl = conn.proc.stdout.read(2) - length = struct.unpack('>H', rawl)[0] - msg = bytes() - while len(msg) < length: - msg += conn.proc.stdout.read(length - len(msg)) - return msg - - fut = self.executor.submit(readmsg, conn) + fut = self.executor.submit(self._readmsg, conn) try: return fut.result(timeout) except futures.TimeoutError: raise test.ValidationError(line, "Timed out") + def wait_for_finalmsg(self, conn): + # We told it to flush gossip every 1000msec, so give 2 seconds here. + while True: + fut = self.executor.submit(self._readmsg, conn) + try: + return fut.result(2) + except futures.TimeoutError: + return None + def expect_tx(self, tx, line): def tx_in_mempool(tx): for txid in self.bitcoind.rpc.getrawmempool(): diff --git a/tools/test-events.py b/tools/test-events.py index bff4c3877..bb08e0195 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -198,6 +198,11 @@ def disconnect(self, conn, line): if self.verbose: print("[DISCONNECT {}]".format(line)) + def wait_for_finalmsg(self, conn): + if self.verbose: + print("[WAIT-FOR-FINAL]") + return None + def recv(self, conn, outbuf, line): if self.verbose: print("[RECV {} {}]".format(line, outbuf.hex())) @@ -637,6 +642,7 @@ class Connection(object): def __init__(self, connkey): self.connkey = connkey self.maybe_sends = [] + self.must_not_sends = [] def __str__(self): return str(self.connkey) @@ -662,6 +668,27 @@ def which_connection(line, runner, connkey): raise LineError(line, "No active 'connect' {}".format(connkey)) +def end_connection(runner, conn, line): + """Helper to wait to see if any must-not-send are triggered at end""" + if conn.must_not_sends == []: + return + + # We assume we don't get an infinite stream of msgs! + while True: + msg = runner.wait_for_finalmsg(conn) + if msg is None: + return + for m in conn.must_not_sends: + if message_match(m.expectmsg, m.expectfields, msg) is None: + raise ValidationError(line, "must-not-send at {} violated by {}" + .format(m.line, msg.hex())) + + # If it was an (unexpected) error, we've failed. + if not runner.expected_error and struct.unpack('>H', msg[0:2]) == (17,): + raise ValidationError(line, + "Unexpected error occurred: {}".format(msg.hex())) + + class NothingEvent(object): def __init__(self, line, parts): parse_params(line, parts, []) @@ -691,6 +718,8 @@ def __init__(self, line, parts): def action(self, runner, line): conn = which_connection(line, runner, self.connkey) + + end_connection(runner, conn, line) runner.disconnect(conn, line) runner.connections.remove(conn) @@ -849,9 +878,10 @@ def maybesend_match(conn, msg): class ExpectSendEvent(object): - def __init__(self, line, parts, maybe=False): + def __init__(self, line, parts, maybe=False, mustnot=False): self.line = line self.maybe = maybe + self.mustnot = mustnot if len(parts) < 1: raise LineError(line, "Missing type=") t = parts[0].partition('=') @@ -893,6 +923,8 @@ def __init__(self, line, parts, maybe=False): self.expectfields[v], _ = f.field_value(line, parts[0]) def __repr__(self): + if self.mustnot: + return "must-not-send:{}:{}".format(self.expectmsg.name, self.line) if self.maybe: return "maybe-send:{}:{}".format(self.expectmsg.name, self.line) return "expect-send:{}:{}".format(self.expectmsg.name, self.line) @@ -903,6 +935,10 @@ def action(self, runner, line): if self.maybe: conn.maybe_sends.append(self) return + # If this is 'must-not-send' then just add it to maybe list. + elif self.mustnot: + conn.must_not_sends.append(self) + return msg = runner.expect_send(conn, line) @@ -1025,6 +1061,8 @@ def __init__(self, args, desc, line): self.actor = ExpectSendEvent(line, parts[1:]) elif parts[0] == 'maybe-send:': self.actor = ExpectSendEvent(line, parts[1:], maybe=True) + elif parts[0] == 'must-not-send:': + self.actor = ExpectSendEvent(line, parts[1:], mustnot=True) elif parts[0] == 'block:': self.actor = BlockEvent(line, parts[1:]) elif parts[0] == 'expect-tx:': @@ -1265,6 +1303,11 @@ def run_test(args, path, runner): runner.expected_error = False for seq in path: seq.run(runner) + + # Make sure they didn't send any must-not-sends at the end. + for conn in runner.connections: + end_connection(runner, conn, path[-1].line) + if not runner.expected_error: error = runner.final_error() if error is not None: From 6dfb24b1f532279179711af324b692952f2c1992 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 2 Aug 2019 23:24:03 -0500 Subject: [PATCH 052/103] protocol tests: handle unpack subtypes Unpacking and comparison for subtypes. --- tools/test-events.py | 68 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 12 deletions(-) diff --git a/tools/test-events.py b/tools/test-events.py index bb08e0195..d0a640da6 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -134,9 +134,8 @@ def unpack_from(typename, bytestream, offset): size = struct.calcsize(name2structfmt[typename]) if size + offset > len(bytestream): return None, None - return (struct.calcsize(name2structfmt[typename]), - struct.unpack_from(name2structfmt[typename], bytestream, - offset)[0]) + return (size, struct.unpack_from(name2structfmt[typename], + bytestream, offset)[0]) # FIXME: This is our non-TLV code if typename.endswith('_tlvs'): @@ -505,16 +504,14 @@ def pack(self, values): def unpack(self, bytestream, offset): """ For every field, unpack it""" - net_size = 0 result = {} lenfields = {} + offset_start = offset for f in self.fields: - off, v = unpack_field(f, lenfields, bytestream, offset) - offset += off - net_size += off + offset, v = unpack_field(f, lenfields, bytestream, offset) result[f.name] = v - return net_size, result + return offset - offset_start, result def compare(self, msgname, vals, expected): if not bool(expected): @@ -557,8 +554,8 @@ def unpack_field(field, lenfields, bytestream, offset): for i in range(0, num): size, var = unpack_from(field.typename, bytestream, offset) if size is None: - return ('Response too short to extract {}[{}]: {}' - .format(field.name, i, bytestream.hex())) + raise ValueError('Response too short to extract {}[{}]: {}' + .format(field.name, i, bytestream.hex())) offset += size v += [var] else: @@ -569,8 +566,8 @@ def unpack_field(field, lenfields, bytestream, offset): v = None size = 0 else: - return ('Response too short to extract {}: {}' - .format(field.name, bytestream.hex())) + raise ValueError('Response too short to extract {} {} ({}): {}' + .format(field.name, field.typename, offset, v)) offset += size # If it's used as a length, save it. @@ -792,6 +789,53 @@ def action(self, runner, line): runner.recv(which_connection(line, runner, self.connkey), self.b, line) +def compare_results(msgname, f, v, exp): + """ f -> field; v -> value; exp -> expected value """ + + # If they specify field=absent, it must not be there. + if exp is None: + if v is not None: + return "Field {} is present" + else: + return None + + if v is None: + return ("Optional field {} is not present" + .format(f.name)) + if isinstance(exp, tuple): + # Out-of-range bitmaps are considered 0 (eg. feature tests) + if len(v) < len(exp[0]): + cmpv = b'\x00' * (len(exp[0]) - len(v)) + v + elif len(v) > len(exp[0]): + cmpv = v[-len(exp[0]):] + else: + cmpv = v + + for i in range(0, len(exp[0])): + if cmpv[i] & exp[1][i] != exp[0][i]: + return ("Expected {}.{} mask 0x{}" + " value 0x{} but got 0x{}" + " (offset {} different)" + .format(msgname, f.name, + exp[1].hex(), exp[0].hex(), + v.hex(), len(exp[0]) - 1 - i)) + # Use subtype comparer + elif f.typename in Subtype.objs: + return Subtype.objs[f.typename].compare(msgname, v[0], exp[0]) + + # Simple comparison + elif v != exp: + if f.isinteger: + valstr = str(v) + expectstr = str(exp) + else: + valstr = v.hex() + expectstr = exp.hex() + return ("Expected {}.{} {} but got {}" + .format(msgname, + f.name, expectstr, valstr)) + return None + def compare_results(msgname, f, v, exp): """ f -> field; v -> value; exp -> expected value """ From 20c1304ce51e56b440314f74a0928714a333d0c2 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Tue, 6 Aug 2019 17:52:19 -0500 Subject: [PATCH 053/103] protcol tests: for c-lightning driver, ensure funds in wallet make sure that the funds have hit the wallet before continuing node operation --- tools/test-events-clightning.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 63026335d..cc054162b 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -100,10 +100,13 @@ def start(self): # Block #1. self.rpc.submitblock('0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f7b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d04283f5a1095dffff7f200100000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0200f2052a01000000160014751e76e8199196d454941c45d1b3a323f1433bd60000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000') self.rpc.generatetoaddress(100, self.rpc.getnewaddress()) + + def activate_funds(self): # This goes into block #101, now we can spend coinbase from #1. self.rpc.sendrawtransaction('020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000') self.rpc.generatetoaddress(1, self.rpc.getnewaddress()) + def stop(self): self.proc.kill() @@ -157,6 +160,21 @@ def node_ready(rpc): raise subprocess.TimeoutExpired(self.proc, "Could not contact lightningd") + # Make sure there's funds in the node wallet before continuing + for i in range(5): + self.rpc.newaddr() + + self.bitcoind.activate_funds() + def see_funds(rpc): + while len(rpc.listfunds()['outputs']) < 1: + time.sleep(0.3) + return True + + if not wait_for(lambda: see_funds(self.rpc)): + raise subprocess.TimeoutExpired(self.proc, + "No funds processed by node after 10s") + + def stop(self): self.rpc.stop() self.bitcoind.stop() From 6592287854ac5b6b7e05c46d7944b4addc65ce58 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Tue, 6 Aug 2019 17:56:15 -0500 Subject: [PATCH 054/103] protocol tests: allow implementation specific flags to be passed in Adds a command flag for command flags. Passed down to the runner on start. Ex: -f max-allowed=0 -f no-fuzz=true --- tools/test-events-clightning.py | 7 ++++++- tools/test-events.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index cc054162b..37d52b0f6 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -131,6 +131,10 @@ def __init__(self, args): os.makedirs(self.lightning_dir) self.lightning_port = reserve() + self.startup_flags = [] + for flag in args.startup_flags: + self.startup_flags.append("--{}".format(flag)) + def start(self): self.proc = subprocess.Popen(['{}/lightningd/lightningd'.format(LIGHTNING_SRC), '--lightning-dir={}'.format(self.lightning_dir), @@ -146,7 +150,8 @@ def start(self): '--bitcoin-rpcpassword=rpcpass', '--bitcoin-rpcport={}'.format(self.bitcoind.port), '--log-level=debug', - '--log-file=log']) + '--log-file=log'] + + self.startup_flags) self.rpc = lightning.LightningRpc(os.path.join(self.lightning_dir, "lightning-rpc")) def node_ready(rpc): diff --git a/tools/test-events.py b/tools/test-events.py index d0a640da6..ee21cfa6b 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -65,6 +65,9 @@ def __call__(self, parser, namespace, values, option_string=None): action="store_true") parser.add_argument('-o', '--option', action=OptionAction, default=[], help='Indicate supported option') + parser.add_argument('-f', '--startup-flags', help="Pass these flags through to daemon " + "under test.\n'--' will be prepended.", + type=str, action="append", default=[]) return parser From d33705e439c477f01ea9a9513980dacd8157b13c Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Tue, 13 Aug 2019 12:06:04 -0500 Subject: [PATCH 055/103] subtypes: match empty values if the values are empty, match them up --- tools/test-events.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/test-events.py b/tools/test-events.py index ee21cfa6b..cbee58c9a 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -824,6 +824,8 @@ def compare_results(msgname, f, v, exp): v.hex(), len(exp[0]) - 1 - i)) # Use subtype comparer elif f.typename in Subtype.objs: + if not v and not exp: + return None return Subtype.objs[f.typename].compare(msgname, v[0], exp[0]) # Simple comparison From 1c740671c508c83a6c51faa649a73db34e6cade2 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 16 Aug 2019 17:18:41 -0500 Subject: [PATCH 056/103] rebase errors, fixup --- tools/test-events.py | 53 +++++--------------------------------------- 1 file changed, 5 insertions(+), 48 deletions(-) diff --git a/tools/test-events.py b/tools/test-events.py index cbee58c9a..cfbe35eb6 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -292,6 +292,11 @@ def field_from_str(line, typename, isinteger, s): except ValueError: raise LineError(line, "Non-hex value for {}: '{}'" .format(typename, s)) + + # FIXME: This is our non-TLV code + if typename.endswith('_tlvs'): + return v + if len(v) != name2size[typename]: raise LineError(line, "{} must be {} bytes long not {}" .format(typename, name2size[typename], len(v))) @@ -842,54 +847,6 @@ def compare_results(msgname, f, v, exp): return None -def compare_results(msgname, f, v, exp): - """ f -> field; v -> value; exp -> expected value """ - - # If they specify field=absent, it must not be there. - if exp is None: - if v is not None: - return "Field {} is present" - else: - return None - - if v is None: - return ("Optional field {} is not present" - .format(f.name)) - if isinstance(exp, tuple): - # Out-of-range bitmaps are considered 0 (eg. feature tests) - if len(v) < len(exp[0]): - cmpv = b'\x00' * (len(exp[0]) - len(v)) + v - elif len(v) > len(exp[0]): - cmpv = v[-len(exp[0]):] - else: - cmpv = v - - for i in range(0, len(exp[0])): - if cmpv[i] & exp[1][i] != exp[0][i]: - return ("Expected {}.{} mask 0x{}" - " value 0x{} but got 0x{}" - " (offset {} different)" - .format(msgname, f.name, - exp[1].hex(), exp[0].hex(), - v.hex(), len(exp[0]) - 1 - i)) - # Use subtype comparer - elif f.typename in Subtype.objs: - return Subtype.objs[f.typename].compare(msgname, v, exp) - - # Simple comparison - elif v != exp: - if f.isinteger: - valstr = str(v) - expectstr = str(exp) - else: - valstr = v.hex() - expectstr = exp.hex() - return ("Expected {}.{} {} but got {}" - .format(msgname, - f.name, expectstr, valstr)) - return None - - def message_match(expectmsg, expectfields, b): """Internal helper to see if b matches expectmsg & expectfields. From afb87dcd2d8e3ddabf3ce6d7772a458db17cf6dd Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 16 Aug 2019 18:04:47 -0500 Subject: [PATCH 057/103] Don't count arrays of bytes as an integer type --- tools/test-events.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/test-events.py b/tools/test-events.py index cfbe35eb6..c0b1853cb 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -247,8 +247,9 @@ def __init__(self, message, name, typename, count, options): self.typename = typename self.options = options self.islenvar = False - # This contains all the integer types: otherwise it's a hexstring - self.isinteger = typename in name2structfmt + # This contains all the integer types: otherwise it's a hexstring, + self.isinteger = (typename in name2structfmt and + not (typename == 'byte' and count)) # This is set for static-sized array. self.arraylen = None From da66e1164d68687917f3317a4004fa16c4488389 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 16 Aug 2019 18:05:47 -0500 Subject: [PATCH 058/103] Allow check for field length instead of contents For dual-funded tests, we need a way to verify that witnesses are the correct length instead of the correct contents. This is a bit 'complicated' because witnesses are in the range of 71-73 bytes long. This patch allows a byte length (or range) to be specified by using `*73` or `*71-73`, as in the case for a range of valid lengths. --- tools/test-events.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/test-events.py b/tools/test-events.py index c0b1853cb..275da35a8 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -312,6 +312,9 @@ def field_value(self, line, value): try: v = bytes.fromhex(value) except ValueError: + if value.startswith('*'): + v = value + return v, v raise LineError(line, "Non-hex value for {} byte array: '{}'" .format(self.name, value)) @@ -837,8 +840,20 @@ def compare_results(msgname, f, v, exp): # Simple comparison elif v != exp: if f.isinteger: + # Instead of checking a field's value, allow a test + # to specify a range of bytelen that's valid. + # This is needed for witness data verifications. + # e.g. *71-73 or *73 for exactly 73 bytes + if isinstance(exp, str) and exp.startswith('*') and check_range(exp[1:], v): + return None valstr = str(v) expectstr = str(exp) + # Same as above note about a range of length + elif exp.startswith('*'): + if check_range(exp[1:], len(v.hex()) // 2): + return None + expectstr = "result of bytelen {}".format(exp[1:]) + valstr = str(len(v.hex()) // 2) else: valstr = v.hex() expectstr = exp.hex() @@ -848,6 +863,16 @@ def compare_results(msgname, f, v, exp): return None +def check_range(exp, val_len): + len_range = exp.split('-') + if len(len_range) > 2: + raise ValueError("Expected size range invalid", exp) + + if len(len_range) == 1: + return int(len_range[0]) == val_len + + return int(len_range[0]) <= val_len and int(len_range[1]) >= val_len + def message_match(expectmsg, expectfields, b): """Internal helper to see if b matches expectmsg & expectfields. From 1a863ac7b36c1174cf544908d3a7b91c6aba3302 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 16 Aug 2019 18:11:12 -0500 Subject: [PATCH 059/103] new event 'wait-funds' New test runner event, gives the node under test time to confirm that they do in fact have funds in their wallet before proceeding. --- tools/test-events-clightning.py | 10 ++++++++++ tools/test-events.py | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 37d52b0f6..4bdd40f87 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -316,6 +316,16 @@ def final_error(self): pass return None + def await_funds(self, timeout): + def see_funds(rpc): + while len(rpc.listfunds()['outputs']) < 1: + time.sleep(0.3) + return True + if not wait_for(lambda: see_funds(self.rpc), timeout=int(timeout)): + raise subprocess.TimeoutExpired(self.proc, + "No funds processed by node after {}s".format(timeout)) + + if __name__ == "__main__": parser = test.setup_cmdline_options() diff --git a/tools/test-events.py b/tools/test-events.py index 275da35a8..ab7ec3e68 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -214,6 +214,11 @@ def fundchannel(self, conn, amount, txid, outnum, line): print("[FUNDCHANNEL TO {} for {} with UTXO {}/{} {}]" .format(conn, amount, txid, outnum, line)) + def await_funds(self, timeout): + if self.verbose: + print("[WAIT-FUNDS FOR UP TO {}s]" + .format(timeout)) + def invoice(self, amount, preimage, line): if self.verbose: print("[INVOICE for {} with PREIMAGE {} {}]" @@ -1038,6 +1043,12 @@ def __init__(self, line, parts): def action(self, runner, line): runner.expect_tx(self.tx, line) +class WaitFunds(object): + def __init__(self, line, parts): + self.timeout = parse_params(line, parts, ['timeout'])['timeout'] + + def action(self, runner, line): + runner.await_funds(self.timeout) class FundChannelEvent(object): def __init__(self, line, parts): @@ -1103,6 +1114,8 @@ def __init__(self, args, desc, line): self.actor = FundChannelEvent(line, parts[1:]) elif parts[0] == 'invoice:': self.actor = InvoiceEvent(line, parts[1:]) + elif parts[0] == 'wait-funds:': + self.actor = WaitFunds(line, parts[1:]) elif parts[0] == 'expect-error:': self.actor = ExpectErrorEvent(line, parts[1:]) elif parts[0] == 'nothing': From 3b1a9a073801e118b8e06d0a69fcb4277014bc50 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 16 Aug 2019 19:14:22 -0500 Subject: [PATCH 060/103] Move funding output block broadcast into tests Allows dual-funding tests to specify a different set of outputs to be used as inputs for the funding transaction --- tests/events/bolt2-01-open_channel.events | 8 ++-- tests/events/bolt2-02-add-htlc.events | 26 ++++++------ tests/events/bolt2-03-htlc-fail.events | 34 ++++++++------- tests/events/bolt2-04-htlc-fulfill.events | 52 ++++++++++++----------- tools/test-events-clightning.py | 17 +------- 5 files changed, 65 insertions(+), 72 deletions(-) diff --git a/tests/events/bolt2-01-open_channel.events b/tests/events/bolt2-01-open_channel.events index e3a6f7311..88b28425d 100644 --- a/tests/events/bolt2-01-open_channel.events +++ b/tests/events/bolt2-01-open_channel.events @@ -1,8 +1,10 @@ # Variations on open_channel. +# +1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 -1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 -2. expect-send: type=init -3. recv: type=init globalfeatures= localfeatures= +2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +3. expect-send: type=init +4. recv: type=init globalfeatures= localfeatures= # We assume a funding_per_kw=253 Satoshi/kSipa. # This gives a channel of 999878sat diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index 0a16dd899..ba412bfac 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -12,10 +12,12 @@ MAYBE_UPDATE=maybe-send: type=channel_update short_channel_id=103x1x0 # FIXME: Fill other expected fields here! -1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 -2. expect-send: type=init -3. recv: type=init globalfeatures= localfeatures=02 -4. recv: type=open_channel +1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 + +2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +3. expect-send: type=init +4. recv: type=init globalfeatures= localfeatures=02 +5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 funding_satoshis=999878 @@ -43,7 +45,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 channel_flags=01 -5. expect-send: type=accept_channel +6. expect-send: type=accept_channel temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a @@ -62,7 +64,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update to_self_delay=6 channel_reserve_satoshis=9998 -6. recv: type=funding_created +7. recv: type=funding_created temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f @@ -71,23 +73,23 @@ MAYBE_UPDATE=maybe-send: type=channel_update # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a -7. expect-send: type=funding_signed +8. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 -8. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 +9. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 -9. expect-send: type=funding_locked +10. expect-send: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 -10. recv: type=funding_locked +11. recv: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # per_commitment_secret #1 = dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d -11. $MAYBE_UPDATE +12. $MAYBE_UPDATE # Optional reconnection testing. 1. nothing @@ -123,7 +125,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 # That aside has nothing to do with the next aside. -12. nothing +13. nothing # Add a dust HTLC 1. recv: type=update_add_htlc diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events index 973d1a357..773625e7a 100644 --- a/tests/events/bolt2-03-htlc-fail.events +++ b/tests/events/bolt2-03-htlc-fail.events @@ -12,10 +12,12 @@ MAYBE_UPDATE=maybe-send: type=channel_update short_channel_id=103x1x0 # FIXME: Fill other expected fields here! -1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 -2. expect-send: type=init -3. recv: type=init globalfeatures= localfeatures=02 -4. recv: type=open_channel +1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 + +2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +3. expect-send: type=init +4. recv: type=init globalfeatures= localfeatures=02 +5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 funding_satoshis=999878 @@ -43,7 +45,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 channel_flags=01 -5. expect-send: type=accept_channel +6. expect-send: type=accept_channel temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a @@ -62,7 +64,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update to_self_delay=6 channel_reserve_satoshis=9998 -6. recv: type=funding_created +7. recv: type=funding_created temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f @@ -71,23 +73,23 @@ MAYBE_UPDATE=maybe-send: type=channel_update # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a -7. expect-send: type=funding_signed +8. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 -8. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 +9. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 -9. expect-send: type=funding_locked +10. expect-send: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 -10. recv: type=funding_locked +11. recv: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # per_commitment_secret #1 = dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d -11. $MAYBE_UPDATE +12. $MAYBE_UPDATE # Add a dust HTLC 1. recv: type=update_add_htlc @@ -200,7 +202,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update 7. $MAYBE_UPDATE # Either way, it should reject HTLC, as it's not a known preimage. -12. expect-send: type=update_fail_htlc +13. expect-send: type=update_fail_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 # FIXME: check that reason is correct! @@ -234,7 +236,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 -13. expect-send: type=commitment_signed +14. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 htlc_signature= @@ -291,7 +293,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect 7. $MAYBE_UPDATE -14. recv: type=revoke_and_ack +15. recv: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 # per_commitment_secret #3=ba65d7b0ef55a3ba300d4e87af29868f394f8f138d78a7011669c79b37b936f4 @@ -322,12 +324,12 @@ MAYBE_UPDATE=maybe-send: type=channel_update my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect 7. $MAYBE_UPDATE -15. recv: type=commitment_signed +16. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 htlc_signature= -16. expect-send: type=revoke_and_ack +17. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index c092e9e00..ed6055d32 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -12,14 +12,16 @@ MAYBE_UPDATE=maybe-send: type=channel_update short_channel_id=103x1x0 # FIXME: Fill other expected fields here! +1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 + # Make two invoices: one is dust, one is not. -1. invoice: amount=1000 preimage=0000000000000000000000000000000000000000000000000000000000001000 -2. invoice: amount=1000000 preimage=0000000000000000000000000000000000000000000000000000000001000000 +2. invoice: amount=1000 preimage=0000000000000000000000000000000000000000000000000000000000001000 +3. invoice: amount=1000000 preimage=0000000000000000000000000000000000000000000000000000000001000000 -3. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 -4. expect-send: type=init -5. recv: type=init globalfeatures= localfeatures=02 -6. recv: type=open_channel +4. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +5. expect-send: type=init +6. recv: type=init globalfeatures= localfeatures=02 +7. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 funding_satoshis=999878 @@ -46,7 +48,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 channel_flags=01 -7. expect-send: type=accept_channel +8. expect-send: type=accept_channel temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a @@ -65,7 +67,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update to_self_delay=6 channel_reserve_satoshis=9998 -8. recv: type=funding_created +9. recv: type=funding_created temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 # Funding tx is 020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f @@ -74,26 +76,26 @@ MAYBE_UPDATE=maybe-send: type=channel_update # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a -9. expect-send: type=funding_signed +10. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 -10. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 +11. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 -11. expect-send: type=funding_locked +12. expect-send: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 -12. recv: type=funding_locked +13. recv: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # per_commitment_secret #1 = dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d -13. $MAYBE_UPDATE +14. $MAYBE_UPDATE # First invoice-paying HTLC -14. recv: type=update_add_htlc +15. recv: type=update_add_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 amount_msat=1000 @@ -103,7 +105,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update # hop_data[0] = 00000000000000000000000000000003E8000000C8000000000000000000000000 onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd9f755853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941ba2804c6057dd454fbb44ad5e52b3383b9bcfda3647eefe650ab93b99ee60c8da -15. recv: type=update_add_htlc +16. recv: type=update_add_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=1 amount_msat=1000000 @@ -113,18 +115,18 @@ MAYBE_UPDATE=maybe-send: type=channel_update # hop_data[0] = 00000000000000000000000000000F4240000000C8000000000000000000000000 onion_routing_packet=0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619b1153ae94698ea83a3298ab3c0ddd6b6fd853e4e5fbc5d4f3cb457bbb74a9b81d3b5bc9cf42d8617d1fe6966ffb66b8ec0eaa1188865957e26df123d11705395d339472bcc4920e428492f7822424eef8e6d903a768ec01959f3a1f2c1cd8725ba13329df3a932f641dee600dbb1a9f3bbe93a167410961f1777a7b48679d8a3041d57c0b8e795ed4884fbb33a2564d4cdafb528c7b63fc31cd2739e71d1d3b56f35ba7976a373b883eed8f1f263aedd540cce9b548e53e58c32ab604195f6004d8d92fe0a9a454229b9bc0795f3e4ccd54089075483afaa0ef3b32ee12cf321052f7b9e5ac1c28169e57d5628c3aee5c775d5fb33ba835fda195981b1e3a06792bdd0ecf85f8f6107fd830ca932e92c6713ea6d4d5129395f54aeabb54debccca130ad019a1f53a20c0c46dd8625ada068e2a13ea5373b60ecdf412728cc78192ae1a56bae26dfb450d2f6b4905e6bd9843fda7df63eb11fb77ce995b25d3076210eca527bb556b4ddc564fa4c6ccb43f1149163a4959ffe4178d653d35bdc052e4a46dd58b8f95fde83d114c4e35fd02e94a0dd2a9ae21594184808074a57d9de30c5105b53efe03aca192f8c518bc2b9e13211a9761c1948b31aa97f99da449968380005f96ff49a6e5fe833220a82f358eb94197584b2dfa5a1efee8918b5020f028748e5897bb694979f580ff58b8b1d865783340eaff2d1ce738409ec1c62c1bd7f632cf0730a5634a1a2d91244b865302339c1861655e11b264aeaf2feefbf2d1222bb13c6bd6b2d2379d9a548f93de4d2a044928458eafa745021e0a69796bb40f17c1ca53b895c76b53924faa886a4a19f07b50eda5f316e5f3b5422e984c59928144c275d4ae5e78634e16c6dafcfc92bb302c7d5eef1456250b0b8a41f0cabb55dd114d6b0bcaf53ef1ee2185d2383df57a0f1bc21d31f5d3ae395bab6e77370ee83ffe8995e9bfbe2f90b3ff0578720e0584e969479d40327415835579d7b8885037c02a611292c6bbffde25e86c184cc7c7481e8856ce6a3cf7109a6c001e51a2289c5ee3633936578d4dc3de82c18ebb787bf2c475e8fa0393727cbdbcd36849ee0b7411fba6fd5cb8459e63aaf3fba7a4cd4a04b266d8f416f0586e2093ea9c210140a6e6cb72759ae1dee7c24497f68389fb8d154f927cc4ab59b9137652eaf9c7cb56f0cce6c58616646c6fee836b07ce738a965b1ea725d9960c47e61086be053f3e9c48c08ce945404b060d9e699ad962c910208dda42d665f8eacf9865a64d2612ea62e0e2c0a4c731b35ae87b04e45739c34f4c972ce433a2094b10a9601e6711b95a6a226a85f4e4ed0e0417dbc9d737cd7d3513a82943de94ff8e4c9e91838506283f4878e3f41488fec47198b4a262b55d3691d275c6154d2a2ce9ee6ab97087e0f33654b01450869797c993dfca76cd732677bf1856f43d040d68022055987588f64af357bea80491b4bc42341dd6f81631d30fc28e8c5d7e3312655b30d277f10ce76c2525279ad53157b1c2c78b412107fc5f974ac7946bdc33ee54d71f3fc261530d50f20813e4e6aadf39e67573d5dc93a45023edf297b56def6b14ec5e19ca10fbfd1b807f17fa983bec363cf495c708a581db1bba1a23730ce22d0f925d764b04be014d662c3a36ac58b015317c9cf5ca6464f2ecef15e1769f2c91922968532bda66e9aaa2a7f120a9301f563fd33db8e90c940984b0a297e0c595544b7f687476325a07dbaba255c8461e98f069eea2246cfa50f1c2ef8d4c54f5fd509a9cc839548d7c252e60bb9c165d05f30bd525f6b53a4c8afc8fc31026686bcd5a48172593941b5be6403eef1373ff72577187afc526cac3c467f07dd00cc91886109c914781d7 -16. recv: type=commitment_signed +17. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=bc5e1b465773cfe59478c5db35e9f9d27bf832436d0ed0c19833b5e7d444e9f26e3522883a110d71e715471727e3ea7703eba0e6e9855e8d59bc0bf93029bb29 htlc_signature=8ef6bc3d35a91a00cd1edb0a22e5ca7204b297d41cd7c4cdb1c4167d2d298d907e23b9dc75356ff2fee9ced4abc9fba796a90a2939df45080d12c7bbadbda8d8 -17. expect-send: type=revoke_and_ack +18. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc # per_commitment_secret 2=2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8 next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad -18. expect-send: type=commitment_signed +19. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=64ce07df4f7d4e3e2a29ae6c78baf1d5087a5028f08f537eaed25a5fd1a1f73836d592ff80ba34bbd8f26a0fee17bc8a1fda64006fa4d28f9d52936e17d0abcb htlc_signature=cfc5c03c510835df5d113b9da9ecdd1b73a602e5bd5a0703c9e53e863da3d8b1193c44913bdc856623f6a706a86256b4939115dec12a79c1f2585cfe7e91a472 @@ -188,7 +190,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect 2. $MAYBE_UPDATE -19. recv: type=revoke_and_ack +20. recv: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 # per_commitment_secret #2=c51a18b13e8527e579ec56365482c62f180b7d5760b46e9477dae59e87ed423a @@ -196,7 +198,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update # It should accept both of them, but could be in any order. # (Could also do this in two separate commits, but I didn't add that). -20. One of: +21. One of: 1. expect-send: type=update_fulfill_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 @@ -216,7 +218,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 # Separator: next is not part of One Of. -21. nothing +22. nothing # Optional reconnection testing. 1. nothing @@ -262,7 +264,7 @@ MAYBE_UPDATE=maybe-send: type=channel_update id=0 payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 -22. expect-send: type=commitment_signed +23. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 htlc_signature= @@ -325,18 +327,18 @@ MAYBE_UPDATE=maybe-send: type=channel_update my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect 2. $MAYBE_UPDATE -23. recv: type=revoke_and_ack +24. recv: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 # per_commitment_secret #3=ba65d7b0ef55a3ba300d4e87af29868f394f8f138d78a7011669c79b37b936f4 next_per_commitment_point=030f1b0e7b158de0d85a05ec050304dcf189c879a888e5ca1ce45e829d4b075d37 -24. recv: type=commitment_signed +25. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=85aebf2874c464db7eac10e0bad98b491c9ac943eae263bb4396d4e5feded12f1284e26196397313be31f4e83334eb5a6641cbec158e0fbfb22c4c488b3a28fd htlc_signature= -25. expect-send: type=revoke_and_ack +26. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 # per_commitment_secret #3=27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116 diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 4bdd40f87..0ecffdfc8 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -101,11 +101,6 @@ def start(self): self.rpc.submitblock('0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f7b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d04283f5a1095dffff7f200100000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff03510101ffffffff0200f2052a01000000160014751e76e8199196d454941c45d1b3a323f1433bd60000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000') self.rpc.generatetoaddress(100, self.rpc.getnewaddress()) - def activate_funds(self): - # This goes into block #101, now we can spend coinbase from #1. - self.rpc.sendrawtransaction('020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000') - self.rpc.generatetoaddress(1, self.rpc.getnewaddress()) - def stop(self): self.proc.kill() @@ -165,20 +160,10 @@ def node_ready(rpc): raise subprocess.TimeoutExpired(self.proc, "Could not contact lightningd") - # Make sure there's funds in the node wallet before continuing + # Make sure that we see any funds that come to our wallet for i in range(5): self.rpc.newaddr() - self.bitcoind.activate_funds() - def see_funds(rpc): - while len(rpc.listfunds()['outputs']) < 1: - time.sleep(0.3) - return True - - if not wait_for(lambda: see_funds(self.rpc)): - raise subprocess.TimeoutExpired(self.proc, - "No funds processed by node after 10s") - def stop(self): self.rpc.stop() From eebe7ae737e9d6c171885a2fcbc9ec03f5ef6acd Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 15:59:58 +0930 Subject: [PATCH 061/103] Revert "new event 'wait-funds'" This reverts commit 09d9c8088eb17ac7206edec93933a91d98feed5d. --- tools/test-events-clightning.py | 10 ---------- tools/test-events.py | 13 ------------- 2 files changed, 23 deletions(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 0ecffdfc8..d02d57268 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -301,16 +301,6 @@ def final_error(self): pass return None - def await_funds(self, timeout): - def see_funds(rpc): - while len(rpc.listfunds()['outputs']) < 1: - time.sleep(0.3) - return True - if not wait_for(lambda: see_funds(self.rpc), timeout=int(timeout)): - raise subprocess.TimeoutExpired(self.proc, - "No funds processed by node after {}s".format(timeout)) - - if __name__ == "__main__": parser = test.setup_cmdline_options() diff --git a/tools/test-events.py b/tools/test-events.py index ab7ec3e68..275da35a8 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -214,11 +214,6 @@ def fundchannel(self, conn, amount, txid, outnum, line): print("[FUNDCHANNEL TO {} for {} with UTXO {}/{} {}]" .format(conn, amount, txid, outnum, line)) - def await_funds(self, timeout): - if self.verbose: - print("[WAIT-FUNDS FOR UP TO {}s]" - .format(timeout)) - def invoice(self, amount, preimage, line): if self.verbose: print("[INVOICE for {} with PREIMAGE {} {}]" @@ -1043,12 +1038,6 @@ def __init__(self, line, parts): def action(self, runner, line): runner.expect_tx(self.tx, line) -class WaitFunds(object): - def __init__(self, line, parts): - self.timeout = parse_params(line, parts, ['timeout'])['timeout'] - - def action(self, runner, line): - runner.await_funds(self.timeout) class FundChannelEvent(object): def __init__(self, line, parts): @@ -1114,8 +1103,6 @@ def __init__(self, args, desc, line): self.actor = FundChannelEvent(line, parts[1:]) elif parts[0] == 'invoice:': self.actor = InvoiceEvent(line, parts[1:]) - elif parts[0] == 'wait-funds:': - self.actor = WaitFunds(line, parts[1:]) elif parts[0] == 'expect-error:': self.actor = ExpectErrorEvent(line, parts[1:]) elif parts[0] == 'nothing': From 50213adcbd02455d0ff6de3ed2eb025c609dd3d5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 16:00:58 +0930 Subject: [PATCH 062/103] test-spec.md: update with length options. Signed-off-by: Rusty Russell --- tests/events/test-spec.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index 1edd7bb90..5b9326ded 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -128,7 +128,8 @@ OUTPUT_EVENT := EXPECT_SEND | MAYBE_SEND | MUST_NOT_SEND | EXPECT_TX | EXPECT_ER EXPECT_SEND := `expect-send:` [CONNSPEC] SPACE+ `type=` TYPENAME SPACE+ SEND_FIELDSPEC* SEND_FIELDSPEC := IDENTIFIER`=`SPECVALUE -SPECVALUE := FIELDVALUE | HEX`/`HEX | `absent` +SPECVALUE := FIELDVALUE | HEX`/`HEX | `absent` | `*`LENGTH_RANGE +LENGTH_RANGE := `*`NUMBER | `*`NUMBER`-`NUMBER MAYBE_SEND := `maybe-send:` [CONNSPEC] SPACE+ `type=` TYPENAME SEND_FIELDSPEC* @@ -139,7 +140,7 @@ EXPECT_TX := `expect-tx:` SPACE+ `tx=`HEX EXPECT_ERROR := `expect-error:` [CONNSPEC] Output events are: -* `expect-send`: a message the implementation is expected to send. Any field specified must match exactly for the test to pass; the value`/`mask notation is used to compare bits against a mask; the field should be zero-padded for comparison if necessary. The special field value `absent` means the (presumably optional) field must not be present. +* `expect-send`: a message the implementation is expected to send. Any field specified must match exactly for the test to pass; the value`/`mask notation is used to compare bits against a mask; the field should be zero-padded for comparison if necessary. `*` is used to specify a length (in bytes) or a length range. The special field value `absent` means the (presumably optional) field must not be present. * `maybe-send`: a message the implementation may send, at any point from now on (until the next `disconnect`) * `must-not-send`: a message the implementation must not send, at any point from now on (until the next `disconnect`). This implies waiting at the end of the test (for a gossip flush!) to make sure it doesn't send it. * `expect-tx`: a transaction the implementation is expected to broadcast. The transactions here assume deterministic signatures. From 5cabd013e8cf1bf5940eb3cd4b844a25a744ae1f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 16:01:58 +0930 Subject: [PATCH 063/103] tools/test-events.py: handle indention which occurs at EOF. Signed-off-by: Rusty Russell --- tools/test-events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-events.py b/tools/test-events.py index 275da35a8..0a19972c2 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -1295,7 +1295,7 @@ def load_sequence(args, lines, linenum, indentlevel, graph): # We expect indented sequences linenum += 1 - while lines[linenum].indentlevel == indentlevel + 1: + while linenum < len(lines) and lines[linenum].indentlevel == indentlevel + 1: # We don't allow sub-nodes here, so terminals will be [child] child, _, linenum = load_sequence(args, lines, linenum, indentlevel + 1, From 00b5f5fed68d90adaa4135d0193851f04f37491c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 16:02:58 +0930 Subject: [PATCH 064/103] fixup invalidation logic --- tools/test-events-clightning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index d02d57268..fb0eb997b 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -206,7 +206,7 @@ def getblockheight(self): def trim_blocks(self, newheight): h = self.bitcoind.rpc.getblockhash(newheight + 1) - self.bitcoind.rpc.invalidateblock([h]) + self.bitcoind.rpc.invalidateblock(h) def add_blocks(self, txs, n, line): for tx in txs: From a959eccbeb51844028d959522e98ed24a8dbb0bf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 16:03:14 +0930 Subject: [PATCH 065/103] tools/test-events-clightning.py: give error location if node disconnects. --- tools/test-events-clightning.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index fb0eb997b..5418ac82f 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -228,12 +228,26 @@ def disconnect(self, conn, line): conn.proc.wait(30) def recv(self, conn, outbuf, line): - rawl = struct.pack('>H', len(outbuf)) - conn.proc.stdin.write(rawl) + try: + rawl = struct.pack('>H', len(outbuf)) + conn.proc.stdin.write(rawl) + + while len(outbuf) != 0: + written = conn.proc.stdin.write(outbuf) + outbuf = outbuf[written:] + except BrokenPipeError: + # This happens when they've sent an error and closed; try + # reading it to figure out what went wrong. + fut = self.executor.submit(self._readmsg, conn) + try: + msg = fut.result(1) + except futures.TimeoutError: + msg = None + if msg: + raise test.ValidationError(line, "Connection closed after sending {}".format(msg.hex())) + else: + raise test.ValidationError(line, "Connection closed") - while len(outbuf) != 0: - written = conn.proc.stdin.write(outbuf) - outbuf = outbuf[written:] # FIXME: Implement fundchannel. # We'll need to import privkey into bitcoind and hand-generate the tx From ad8ff1c906304055732a5bc39f1dae397f425d7a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 16:03:14 +0930 Subject: [PATCH 066/103] fix up 'conn=' parsing. Signed-off-by: Rusty Russell --- tests/events/bolt1-01-init.events | 2 +- tests/events/bolt1-02-unknown-messages.events | 2 +- tools/test-events.py | 79 +++++++++++-------- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/tests/events/bolt1-01-init.events b/tests/events/bolt1-01-init.events index 4eea9e6b7..78b3ec0f3 100644 --- a/tests/events/bolt1-01-init.events +++ b/tests/events/bolt1-01-init.events @@ -5,7 +5,7 @@ EXPECT_INIT=expect-send: type=init 1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 -2. $EXPECT_INIT conn=0000000000000000000000000000000000000000000000000000000000000003 +2. $EXPECT_INIT 3. recv: type=init globalfeatures= localfeatures= 1. nothing diff --git a/tests/events/bolt1-02-unknown-messages.events b/tests/events/bolt1-02-unknown-messages.events index ab5949416..8881aa36d 100644 --- a/tests/events/bolt1-02-unknown-messages.events +++ b/tests/events/bolt1-02-unknown-messages.events @@ -9,7 +9,7 @@ # - MUST fail the connection. 1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 -2. expect-send: type=init conn=0000000000000000000000000000000000000000000000000000000000000003 +2. expect-send: type=init 3. recv: type=init globalfeatures= localfeatures= 1. nothing diff --git a/tools/test-events.py b/tools/test-events.py index 0a19972c2..b3f43d270 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -614,24 +614,30 @@ def read_csv(args): subtype.addField(Field(subtype, parts[2], parts[3], parts[4], parts[5:])) +def line_keyval(line, part): + """Return , from key=val part of line, or raise LineError""" + p = part.partition('=') + if p[1] != '=': + raise LineError(line, "Malformed key {} does not contain '='" + .format(part)) + return p[0], p[2] + + def parse_params(line, parts, compulsorykeys, optionalkeys=[]): """Given an array of = make a dict, checking we have all compulsory # keys.""" ret = {} for i in parts: - p = i.partition('=') - if p[1] != '=': - raise LineError(line, "Malformed key {} does not contain '='" - .format(i)) - if p[0] in ret.keys(): - raise LineError(line, "Duplicate key {}".format(p[0])) - if p[0] in compulsorykeys: - compulsorykeys.remove(p[0]) - elif p[0] in optionalkeys: - optionalkeys.remove(p[0]) + k, v = line_keyval(line, i) + if k in ret.keys(): + raise LineError(line, "Duplicate key {}".format(k)) + if k in compulsorykeys: + compulsorykeys.remove(k) + elif k in optionalkeys: + optionalkeys.remove(k) else: - raise LineError(line, "Unknown key {}".format(p[0])) - ret[p[0]] = p[2] + raise LineError(line, "Unknown key {}".format(k)) + ret[k] = v if compulsorykeys != []: raise LineError(line, "No specification for key {}" @@ -665,6 +671,26 @@ def optional_connection(line, params): return ret +def optional_connection_then_type(line, parts): + """Trivial helper to extract & remove conn= and type= from parts""" + if len(parts) < 1: + raise LineError(line, "Missing type=") + + k, v = line_keyval(line, parts.pop(0)) + if k == 'conn': + check_hex(line, v, 64) + conn = v + if len(parts) < 1: + raise LineError(line, "Missing type=") + k, v = line_keyval(line, parts.pop(0)) + else: + conn = None + + if k != 'type': + raise LineError(line, "Expected type=") + return conn, v + + def which_connection(line, runner, connkey): """Helper to get the conn they asked for, or default if connkey=None""" if connkey is None: @@ -735,20 +761,16 @@ def action(self, runner, line): class RecvEvent(object): def __init__(self, line, parts): - if len(parts) < 1: - raise LineError(line, "Missing type=") - t = parts[0].partition('=') - if t[1] != '=': - raise LineError(line, "Expected type=") + self.connkey, t = optional_connection_then_type(line, parts) - msg = find_message(messages, t[2]) + msg = find_message(messages, t) if not msg: # Allow raw integers. - msg = Message('unknown', t[2]) + msg = Message('unknown', t) # See what fields are allowed. fields = [] - optfields = ['conn', 'extra'] + optfields = ['extra'] for f in msg.fields: # Lengths are implied if f.islenvar: @@ -760,8 +782,7 @@ def __init__(self, line, parts): fields.append(f.name) # This fails if non-optional fields aren't specified. - d = parse_params(line, parts[1:], fields, optfields) - self.connkey = optional_connection(line, d) + d = parse_params(line, parts, fields, optfields) # Now get values for assembling the message. values = {} @@ -914,18 +935,15 @@ def __init__(self, line, parts, maybe=False, mustnot=False): self.line = line self.maybe = maybe self.mustnot = mustnot - if len(parts) < 1: - raise LineError(line, "Missing type=") - t = parts[0].partition('=') - if t[1] != '=': - raise LineError(line, "Expected type=") - self.expectmsg = find_message(messages, t[2]) + self.connkey, t = optional_connection_then_type(line, parts) + + self.expectmsg = find_message(messages, t) if not self.expectmsg: raise LineError(line, "Unknown message type") self.expectfields = {} - optfields = ['conn'] + optfields = [] for f in self.expectmsg.fields: # Lengths are implied if f.islenvar: @@ -933,8 +951,7 @@ def __init__(self, line, parts, maybe=False, mustnot=False): optfields.append(f.name) # All fields are optional - d = parse_params(line, parts[1:], [], optfields) - self.connkey = optional_connection(line, d) + d = parse_params(line, parts, [], optfields) for v in d.keys(): # IDENTIFIER`=`FIELDVALUE | IDENTIFIER`=`HEX/HEX | `absent` From 3edaa8ab3fda0373dbe0ca7725687aa7d1f79c6a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 16:03:14 +0930 Subject: [PATCH 067/103] give proper information when unknown event type --- tools/test-events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-events.py b/tools/test-events.py index b3f43d270..e3d5c0c03 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -1125,7 +1125,7 @@ def __init__(self, args, desc, line): elif parts[0] == 'nothing': self.actor = NothingEvent(line, parts[1:]) else: - raise ValueError("Unknown event type {}".format(parts[0])) + raise LineError(line, "Unknown event type {}".format(parts[0])) def __repr__(self): return "Event({}, {})".format(self.event, str(self.line)) From cbdca18dfdb87d1d07b8cd043395b12a5f6a5691 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 28 Aug 2019 16:04:52 +0930 Subject: [PATCH 068/103] Implement 'Any order'. Otherwise combinatorial explosion buries us in gossip alternatives. Signed-off-by: Rusty Russell --- tests/events/bolt2-04-htlc-fulfill.events | 35 +------- tests/events/test-spec.md | 26 ++++-- tools/test-events.py | 100 ++++++++++++++++++++-- 3 files changed, 117 insertions(+), 44 deletions(-) diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index ed6055d32..620d0116a 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -198,26 +198,17 @@ MAYBE_UPDATE=maybe-send: type=channel_update # It should accept both of them, but could be in any order. # (Could also do this in two separate commits, but I didn't add that). -21. One of: +21. Any order: 1. expect-send: type=update_fulfill_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 - 2. expect-send: type=update_fulfill_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=1 - payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 - 1. expect-send: type=update_fulfill_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=1 payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 - 2. expect-send: type=update_fulfill_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=0 - payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 -# Separator: next is not part of One Of. +# Separator: next is not part of Any order. 22. nothing # Optional reconnection testing. @@ -245,24 +236,15 @@ MAYBE_UPDATE=maybe-send: type=channel_update my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect 7. $MAYBE_UPDATE # Now it will re-transmit - 8. One of: + 8. Any order: 1. expect-send: type=update_fulfill_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 - 2. expect-send: type=update_fulfill_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=1 - payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 - 1. expect-send: type=update_fulfill_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=1 payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 - 2. expect-send: type=update_fulfill_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=0 - payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 23. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -295,24 +277,15 @@ MAYBE_UPDATE=maybe-send: type=channel_update my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect 2. $MAYBE_UPDATE # Now it will re-transmit - 3. One of: + 3. Any order: 1. expect-send: type=update_fulfill_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=0 payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 - 2. expect-send: type=update_fulfill_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=1 - payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 - 1. expect-send: type=update_fulfill_htlc channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 id=1 payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 - 2. expect-send: type=update_fulfill_htlc - channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - id=0 - payment_preimage=0000000000000000000000000000000000000000000000000000000000001000 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index 5b9326ded..84d351688 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -13,9 +13,9 @@ FILE := SEQUENCE* SEQUENCE := SEQUENCE_LINE+ SEQUENCE_LINE := SEQUENCE_STEP OPTION_SPEC* | META_LINE -SEQUENCE_STEP := INDENT4* NUMBER `.` SPACE+ EVENT_OR_ONEOF OPTION_SPEC* +SEQUENCE_STEP := INDENT4* NUMBER `.` SPACE+ EVENT_OR_SERIES OPTION_SPEC* -EVENT_OR_ONEOF := EVENT | `One of:` +EVENT_OR_SERIES := EVENT | `One of:` | `Any order:` EVENT := INPUT_EVENT | OUTPUT_EVENT | `nothing` META_LINE := COMMENT | SPACE* | VARSET | INCLUDE @@ -52,9 +52,25 @@ same level, in which case it follows the previous. There must be exactly one top-level `1.` step. -The special marker 'One of:' indicate sequences starting with distinct -output events which could occur in any order. This is common for -gossip output which may be in various orders: +The special marker `Any order:` indicates that the following sequences +starting with distinct output events will occur, but might happen in +any order. This is useful for gossip messages which can be ordered in +multiple ways: + + 1. STEP1 + 2. Any order: + 1. STEP2a + 1. STEP2b + 1. STEP2c + +This means the test will accept STEP1->STEP2a->STEP2b->STEP2c, +STEP1->STEP2a->STEP2c->STEP2b, STEP1->STEP2b->STEP2a->STEP2c, +STEP1->STEP2b->STEP2c->STEP2a, STEP1->STEP2c->STEP2a->STEP2b, +or STEP1->STEP2c->STEP2b->STEP2c. + +The special marker `One of:` indicate sequences starting with distinct +output events, only one of which could occur. This is useful for optional +outputs which are more constrained, eg: 1. STEP1 2. One of: diff --git a/tools/test-events.py b/tools/test-events.py index e3d5c0c03..86720ec25 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -1183,6 +1183,17 @@ def run(self, runner, start=0): e.act(runner) +def match_which_sequence(msg, sequences): + """Return which sequence starts with expect-msg: msg, or None""" + for s in sequences: + failreason = message_match(s.events[0].actor.expectmsg, + s.events[0].actor.expectfields, msg) + if failreason is None: + return s + + return None + + class OneOfEvent(object): """Event representing multiple possible sequences""" def __init__(self, args, line): @@ -1232,13 +1243,11 @@ def act(self, runner): conn = which_connection(self.line, runner, self.connkey) while True: msg = runner.expect_send(conn, self.line) - for s in self.sequences: - failreason = message_match(s.events[0].actor.expectmsg, - s.events[0].actor.expectfields, msg) - if failreason is None: - # We found the sequence, run the rest of it. - s.run(runner, start=1) - return + s = match_which_sequence(msg, self.sequences) + if s is not None: + # We found the sequence, run the rest of it. + s.run(runner, start=1) + return if maybesend_match(conn, msg): continue @@ -1248,6 +1257,66 @@ def act(self, runner): .format(msg.hex())) +class AnyOrderEvent(object): + """Event representing sequences in any order""" + def __init__(self, args, line): + self.line = line + self.args = args + self.sequences = [] + + def __str__(self): + return str(self.line) + + def flatten(self, number, stopline, prefix): + # FIXME: if stopline is in here, we ignore it + _, number = self.line.flatten(number, stopline, prefix) + i = 1 + for s in self.sequences: + _, i = s.flatten(i, stopline, ' ') + return False, number + + def num_steps(self): + return sum([s.num_steps() for s in self.sequences]) + + def add_sequence(self, seq): + actor = seq.events[0].actor + if type(actor) != ExpectSendEvent: + # We could relax this a bit if necessary, eg 'expect-error' or + # 'expect-tx' would be possible. + raise LineError(seq.events[0].line, + "First sequence event in Any Order must be expect-send") + # They have to match on what conn the specify, too. + if len(self.sequences) != 0: + if actor.connkey != self.connkey: + raise LineError(seq.events[0].line, + "All first sequence event in Any Order must same conn=") + else: + self.connkey = actor.connkey + self.sequences.append(seq) + + def act(self, runner): + if self.args.verbose: + print("# running {}".format(self)) + + # For DummyRunner, we assume the first. + if type(runner) == DummyRunner: + return self.sequences[0].run(runner) + + conn = which_connection(self.line, runner, self.connkey) + sequences = self.sequences[:] + while sequences != []: + msg = runner.expect_send(conn, self.line) + s = match_which_sequence(msg, sequences) + + if s is not None: + sequences.remove(s) + s.run(runner, start=1) + elif not maybesend_match(conn, msg): + raise ValidationError(self.line, + "None of the sequences matched {}" + .format(msg.hex())) + + # Loads a Sequence at this indent level (and any children embedded in # it, if allow_children). Returns the initial Sequence, a list of # Sequence leaves, and the next linenum. @@ -1276,7 +1345,7 @@ def load_sequence(args, lines, linenum, indentlevel, graph): if lines[linenum].indentlevel == indentlevel + 1: if graph is None: raise LineError(lines[linenum], - "Cannot have indentations inside 'One of'") + "Cannot have indentations inside 'One of'/'Any order'") child, childterms, linenum = load_sequence(args, lines, linenum, indentlevel + 1, graph) @@ -1322,6 +1391,21 @@ def load_sequence(args, lines, linenum, indentlevel, graph): if event.sequences == []: raise LineError(lines[linenum], "Expected indented sequences after 'One of:'") + elif parts[2].split() == ['Any', 'order:']: + event = AnyOrderEvent(args, lines[linenum]) + + # We expect indented sequences + linenum += 1 + while linenum < len(lines) and lines[linenum].indentlevel == indentlevel + 1: + # We don't allow sub-nodes here, so terminals will be [child] + child, _, linenum = load_sequence(args, lines, linenum, + indentlevel + 1, + None) + event.add_sequence(child) + + if event.sequences == []: + raise LineError(lines[linenum], + "Expected indented sequences after 'Any order:'") else: event = Event(args, parts[2], lines[linenum]) linenum += 1 From 487cc6114fbf39855c5c816854d8d1937fcfb4d8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:19:55 +0930 Subject: [PATCH 069/103] handle tlvs in a slightly less hacky way. We still treat them as blobs of hex, but we don't base it on the suffix. Signed-off-by: Rusty Russell --- tools/test-events.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tools/test-events.py b/tools/test-events.py index 86720ec25..dffb5437a 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -18,6 +18,9 @@ # Populated by read_csv messages = [] +# Populated by read_csv +tlvstreams = set() + # From 01-messaging.md#fundamental-types: name2size = {'byte': 1, 'u16': 2, @@ -120,7 +123,7 @@ def pack(typename, v): return struct.pack(name2structfmt[typename], v) # FIXME: This is our non-TLV code - if typename.endswith('_tlvs'): + if typename in tlvstreams: return v if typename in Subtype.objs: @@ -141,7 +144,7 @@ def unpack_from(typename, bytestream, offset): bytestream, offset)[0]) # FIXME: This is our non-TLV code - if typename.endswith('_tlvs'): + if typename in tlvstreams: return len(bytestream) - offset, bytestream[offset:] if typename in Subtype.objs: @@ -264,6 +267,10 @@ def __init__(self, message, name, typename, count, options): self.arrayvar = message.findField(count) self.arrayvar.islenvar = True + def is_optional(self): + """TLVs are always considered optional""" + return self.options != [] or self.typename in tlvstreams + @staticmethod def field_from_str(line, typename, isinteger, s): if typename == "short_channel_id": @@ -295,7 +302,7 @@ def field_from_str(line, typename, isinteger, s): .format(typename, s)) # FIXME: This is our non-TLV code - if typename.endswith('_tlvs'): + if typename in tlvstreams: return v if len(v) != name2size[typename]: @@ -324,6 +331,9 @@ def field_value(self, line, value): "{} byte array should be length {} not {}" .format(self.name, self.arraylen, len(v))) return v, len(v) + elif self.typename in tlvstreams: + v = bytes.fromhex(value) + return v, len(v) elif self.typename in Subtype.objs: # Subtypes subtype = Subtype.objs[self.typename] return subtype.parse(line, value) @@ -574,7 +584,7 @@ def unpack_field(field, lenfields, bytestream, offset): size, v = unpack_from(field.typename, bytestream, offset) if size is None: # Optional fields might not exist - if field.options != []: + if field.is_optional(): v = None size = 0 else: @@ -612,6 +622,8 @@ def read_csv(args): # Insert fields into dict for subtype subtype = Subtype.objs[parts[1]] subtype.addField(Field(subtype, parts[2], parts[3], parts[4], parts[5:])) + elif parts[0] == 'tlvtype': + tlvstreams.add(parts[1]) def line_keyval(line, part): @@ -776,7 +788,7 @@ def __init__(self, line, parts): if f.islenvar: continue # Optional fields are, um, optional. - if f.options: + if f.is_optional(): optfields.append(f.name) else: fields.append(f.name) @@ -965,8 +977,8 @@ def __init__(self, line, parts, maybe=False, mustnot=False): raise LineError(line, "Unequal value/mask lengths") else: if parts[0] == 'absent': - if f.options == []: - raise LineError(line, "Field is not optional") + if not f.is_optional(): + raise LineError(line, "{} is not optional".format(f.name)) self.expectfields[v] = None else: self.expectfields[v], _ = f.field_value(line, parts[0]) From 86926b0a0f5b3e7717d1b160cd7293e4726a2fca Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:19:57 +0930 Subject: [PATCH 070/103] Fix parsing of signature hex fields. Signed-off-by: Rusty Russell --- tools/test-events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-events.py b/tools/test-events.py index dffb5437a..6d63e54e8 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -882,7 +882,7 @@ def compare_results(msgname, f, v, exp): valstr = str(v) expectstr = str(exp) # Same as above note about a range of length - elif exp.startswith('*'): + elif isinstance(exp,str) and exp.startswith('*'): if check_range(exp[1:], len(v.hex()) // 2): return None expectstr = "result of bytelen {}".format(exp[1:]) From e7380c22bd641327120964527a5df00dff5f320f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:19:57 +0930 Subject: [PATCH 071/103] Add setup.incl which contains convenience vars. Signed-off-by: Rusty Russell --- tests/events/bolt2-01-open_channel.events | 4 +- tests/events/bolt2-02-add-htlc.events | 4 +- tests/events/bolt2-03-htlc-fail.events | 4 +- tests/events/bolt2-04-htlc-fulfill.events | 4 +- tests/events/setup.incl | 81 +++++++++++++++++++++++ tests/events/test-spec.md | 38 +---------- 6 files changed, 95 insertions(+), 40 deletions(-) create mode 100644 tests/events/setup.incl diff --git a/tests/events/bolt2-01-open_channel.events b/tests/events/bolt2-01-open_channel.events index 88b28425d..40b269baf 100644 --- a/tests/events/bolt2-01-open_channel.events +++ b/tests/events/bolt2-01-open_channel.events @@ -1,6 +1,8 @@ # Variations on open_channel. # -1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 +include setup.incl + +1. block: $BLOCK_102 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index ba412bfac..9c40c0119 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -12,7 +12,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update short_channel_id=103x1x0 # FIXME: Fill other expected fields here! -1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 +include setup.incl + +1. block: $BLOCK_102 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events index 773625e7a..bd98916e4 100644 --- a/tests/events/bolt2-03-htlc-fail.events +++ b/tests/events/bolt2-03-htlc-fail.events @@ -12,7 +12,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update short_channel_id=103x1x0 # FIXME: Fill other expected fields here! -1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 +include setup.incl + +1. block: $BLOCK_102 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index 620d0116a..a24a7708d 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -12,7 +12,9 @@ MAYBE_UPDATE=maybe-send: type=channel_update short_channel_id=103x1x0 # FIXME: Fill other expected fields here! -1. block: height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 +include setup.incl + +1. block: $BLOCK_102 # Make two invoices: one is dust, one is not. 2. invoice: amount=1000 preimage=0000000000000000000000000000000000000000000000000000000000001000 diff --git a/tests/events/setup.incl b/tests/events/setup.incl new file mode 100644 index 000000000..ba8d2ee94 --- /dev/null +++ b/tests/events/setup.incl @@ -0,0 +1,81 @@ +# Include this to create channels and set variables for gossip messages. + +# BLOCK_102 allows funding of channels with several UTXOs for easy testing. +# +# Here are the keys to spend funds, derived from BIP32 seed +# `0000000000000000000000000000000000000000000000000000000000000001`: +# +# pubkey 0/0/1: 02d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b +# privkey 0/0/1: 76edf0c303b9e692da9cb491abedef46ca5b81d32f102eb4648461b239cb0f99 +# WIF 0/0/1: cRZtHFwyrV3CS1Muc9k4sXQRDhqA1Usgi8r7NhdEXLgM5CUEZufg +# P2WPKH 0/0/1: bcrt1qsdzqt93xsyewdjvagndw9523m27e52er5ca7hm +# UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1 (0.01BTC) +# +# pubkey 0/0/2: 038f1573b4238a986470d250ce87c7a91257b6ba3baf2a0b14380c4e1e532c209d +# privkey 0/0/2: bc2f48a76a6b8815940accaf01981d3b6347a68fbe844f81c50ecbadf27cd179 +# WIF 0/0/2: cTtWRYC39drNzaANPzDrgoYsMgs5LkfE5USKH9Kr9ySpEEdjYt3E +# P2WPKH 0/0/2: bcrt1qlkt93775wmf33uacykc49v2j4tayn0yj25msjn +# UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/0 (0.02BTC) +# +# pubkey 0/0/3: 02ffef0c295cf7ca3a4ceb8208534e61edf44c606e7990287f389f1ea055a1231c +# privkey 0/0/3: 16c5027616e940d1e72b4c172557b3b799a93c0582f924441174ea556aadd01c +# WIF 0/0/3: cNLxnoJSQDRzXnGPr4ihhy2oQqRBTjdUAM23fHLHbZ2pBsNbqMwb +# P2WPKH 0/0/3: bcrt1q2ng546gs0ylfxrvwx0fauzcvhuz655en4kwe2c +# UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/3 (0.03BTC) +# +# pubkey 0/0/4: 026957e53b46df017bd6460681d068e1d23a7b027de398272d0b15f59b78d060a9 +# privkey 0/0/4: 53ac43309b75d9b86bef32c5bbc99c500910b64f9ae089667c870c2cc69e17a4 +# WIF 0/0/4: cQPMJRjxse9i1jDeCo8H3khUMHYfXYomKbwF5zUqdPrFT6AmtTbd +# P2WPKH 0/0/4: bcrt1qrdpwrlrmrnvn535l5eldt64lxm8r2nwkv0ruxq +# UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/4 (0.04BTC) +# +# pubkey 0/0/5: 03a9f795ff2e4c27091f40e8f8277301824d1c3dfa6b0204aa92347314e41b1033 +# privkey 0/0/5: 16be98a5d4156f6f3af99205e9bc1395397bca53db967e50427583c94271d27f +# WIF 0/0/5: cNLuxyjvR6ga2q6fdmSKxAd1CPQDShKV9yoA7zFKT7GJwZXr9MmT +# P2WPKH 0/0/5: bcrt1q622lwmdzxxterumd746eu3d3t40pq53p62zhlz +# UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/2 (49.89995320BTC) + +BLOCK_102=height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 + +# Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000010 and 0000000000000000000000000000000000000000000000000000000000000020 (txid 189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c756031 +BLOCK_103=height=103 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c5410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d8187117382024730440220798d96d5a057b5b7797988a855217f41af05ece3ba8278366e2f69763c72e785022065d5dd7eeddc0766ddf65557c92b9c52c301f23f94d2cf681860d32153e6ae1e012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + +# This channel claimed by nodeids with privkeys ...002 and ...003. +CHAN_ANN_103x1x0=type=channel_announcement node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + +CHAN_UPDATE_103x1x0_002=type=channel_update signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 message_flags=0 channel_flags=0 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 + +NODE_ANN_002=type=node_announcement signature=f48cc073f61994f978d6fc483cf477bdfd5c754d5deaf055af161fda9039831469432b5d4a08e95242498accf7324dc5918c8efe33dc5c65e17c90121c13320b features= timestamp=1565587763 node_id=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 rgb_color=02c604 alias=3032633630343766393434316564376436643330343534303665393563303763 addresses=01080808082607 + +CHAN_UPDATE_103x1x0_003=type=channel_update signature=0b20265c60b98d6150097ea2ed73a0df4c870ed13defde348c799dd418671ca814837b7b46733d3f28f63b4f36768b44f6ec8dc52fbb08103e27c85ab1188c60 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 message_flags=1 channel_flags=1 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 + +NODE_ANN_003=type=node_announcement signature=d0b8131bac61b20ecfd04f4ddd7042b98e140bc43ed5ab362ac29516bf0e7fce2c92b1e0f39de68afca2ab8cd1d1205a4847f3116c210b9352fba2d628c9b458 features= timestamp=1565587763 node_id=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 rgb_color=02f930 alias=3032663933303861303139323538633331303439333434663835663839643532 addresses=0151b6887026070220014c4e1cc141001e6f65fffec8a825260703c43068ceb641d7b25c3a26070441cf248da2034dfa9351a9e946d71ce86f561f50b67753fd8e385d44647bf62cdb91032607 + +# A later node-announcement, a little different. +NODE_ANN_003_LATER=type=node_announcement signature=9accff5a0d434eb09b5a3b594af3adc675e223f200a2d488947c6fca39115c885bf87b69963bcac430d0267ef15fe6f7abfa84d4b9be2bb0ee17822d1c02af41 features= timestamp=1565597764 node_id=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 rgb_color=02f930 alias=3032663933303861303139323538633331303439333434663835663839643532 addresses=0441cf248da2034dfa9351a9e946d71ce86f561f50b67753fd8e385d44647bf62cdb91032607 + +# Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/0, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000030 and 0000000000000000000000000000000000000000000000000000000000000040 (txid db029ee8cc511625887c192c5bb264249fe69b9b86eb627a52f9a313ba231ade) +BLOCK_109=height=109 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160000000000ffffffff0105841e0000000000220020fa73be60259cea454ee79a963514f0b7622db62eadc88daafe377bfa2aa30fbb0247304402205735b9750a90be1ca09cdf91d6697bde3746a390698ca754d516b56c72880bae02203c1deef3645cc20e300db1a808ffc7c2f57be200761ee3cf1a479d1e1aef70bc0121038f1573b4238a986470d250ce87c7a91257b6ba3baf2a0b14380c4e1e532c209d00000000 + +# This channel claimed by nodeids with privkeys ...004 and ...005. +CHAN_ANN_109x1x0=type=channel_announcement node_signature_1=764be32b3a8839a171a8ad9ef25d326d5c58160029006733ea06978e2806789024a1516575f69c957db8beeb3e5e1452e48db1b3ee085f3d623b47a986539783 node_signature_2=4f71e2785eb9d3833f307f8d954bc7b80f47bdcf483ff41ed9354143dbf62e1b50e31b9f735a26dc1d1ae78e857e0e727761faeaf60c9326cffd232f6ffd74e6 bitcoin_signature_1=8dd1cc39900c5728645b8a031e614b491abb36ff2aa3b529da7bce7091f28d6f237358c168f38a933ed483d9d582af45ee2b078ac9174751a9a4613c3fe4e8e7 bitcoin_signature_2=0bde268ccf1f1e7b245cd23d68e8bda0cb2fe42672bbe693a6a5cf85033fadbe069330dc785665ce8306946d00c16e40035e99db3daf4e1a087ca655f093b14a features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 node_id_1=022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4 node_id_2=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 bitcoin_key_1=03bf23c1542d16eab70b1051eaf832823cfc4c6f1dcdbafd81e37918e6f874ef8b bitcoin_key_2=026eca335d9645307db441656ef4e65b4bfc579b27452bebc19bd870aa1118e5c3 + +CHAN_UPDATE_109x1x0_004=type=channel_update signature=e4328bdcc06a311030d494ee391e000ca8bcdff59f0d071fce10253d43ba65e778c0540c11fb6417a43031da25c5a7b2c38122e92a7111760261967802128219 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 timestamp=1565587764 message_flags=0 channel_flags=1 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 + +NODE_ANN_004=type=node_announcement signature=189a566e9718c5ead7ac99956c0297b56c54bb304c99d3f02235712a376ad09f683cdd8d94d3c71c82fae2a08ea2495cca31426b6d4ec5ac35e83361c15633ef features= timestamp=1565587764 node_id=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 rgb_color=02e493 alias=3032653439336462663163313064383066333538316534393034393330623134 addresses= + +NODE_ANN_004_LATER=type=node_announcement signature=3370d9ada9e7b19e81425b32c2f05c5acb650f7ecb45ddb16eec922b1af956c23df932d7b13f6e7e0f230b1565df6ae7e0f7c4251d9a6805e3ef6057dd467cac features= timestamp=1565597765 node_id=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 rgb_color=02e493 alias=3032653439336462663163313064383066333538316534393034393330623134 addresses= + +CHAN_UPDATE_109x1x0_005=type=channel_update signature=06737e9e18d3e4d0ab4066ccaecdcc10e648c5f1c5413f1610747e0d463fa7fa39c1b02ea2fd694275ecfefe4fe9631f24afd182ab75b805e16cd550941f858c chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 timestamp=1565587765 message_flags=1 channel_flags=0 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 + +NODE_ANN_005=type=node_announcement signature=7a553b3933cb5974997c3e294a46ea474a435df2c0d82a0732c0c9700b04e2a6492b2a0620dcfd68e8e64c35b867bc3ec5df4393e3fc3b397095768e2362bae2 features= timestamp=1565587765 node_id=022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4 rgb_color=022f8b alias=3032326638626465346431613037323039333535623461373235306135633531 addresses=022a03b0c0000300d000000000240020012607 + +# Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/3, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000050 and 0000000000000000000000000000000000000000000000000000000000000060 (txid 03330f41079aba9a595310c9c4d78676e5291ee6f1931dd7686f46ed16096186) +BLOCK_115=height=115 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160300000000ffffffff0145c62d00000000002200208225164b456194e9721a5ff5ea4df731d3d663f48f3ba96961dc9d0617ea2bf20247304402200bf2e7a300f8d268c9480732748707b36e43f6225f5330eca2cfa00b21c7159a02205390a3469a14b3a48714bb44db6d8ee838ef5e29b3063a32cba22a3a2d4f3e00012102ffef0c295cf7ca3a4ceb8208534e61edf44c606e7990287f389f1ea055a1231c00000000 + +# This channel claimed by nodeids with privkeys ...003 and ...004. +CHAN_ANN_115x1x0=type=channel_announcement node_signature_1=91d93a0ac557d03c0cb78b7699ad70ab2e86aed6e1780bd5381637bedbfe202938109484eee1a36a33aa7e0149fa062c502261564e4ecdbebdad5d32657efb82 node_signature_2=dc8cfdb6cdcde9e760f6b21f4d6ce7fe7569143aa253e1ae5339d96b9654422715ca0909f50b612818f9bb9e91fa4729d80d9fe3c16a9af821260a2c1c91888e bitcoin_signature_1=57543ea23aae8231dbe25a89ad1e6d32a4d17f27a84402d7535ec6af3d5c185645d98f605737bc7367660e6084f3d3a2ed2c8a6401feb71057d48f2de5f0961f bitcoin_signature_2=f19424a474fe2d1b573333d0783591a5478616d498f3331d6d0f32f570bce84862731442f0b1d04fa8f94a3bd639e8e7cb1ad5e96795b36f538ab45a90da4a90 features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 node_id_1=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 bitcoin_key_1=033f0e80e574456d8f8fa64e044b2eb72ea22eb53fe1efe3a443933aca7f8cb0e3 bitcoin_key_2=03e9623bbef1bf90ec0d7c744ed34659f010e6e638637161270ecd31e14f87f62e + +CHAN_UPDATE_115x1x0_003=type=channel_update signature=d920087673273a3221e6bf8671e1e3e0b20319c5dd87233c6525a90acaded2c032386032657daccf33e08e9aeb5a590300eb58a3943a89e73814bbf930d72391 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 timestamp=1565597764 message_flags=0 channel_flags=1 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 + +CHAN_UPDATE_115x1x0_004=type=channel_update signature=ca7bb2adea595eeb448c0139136196557f9f7b52ea0e3d85634bf8d7dd99096440e06e55d2874506ab6dd8d3b9285c0282dae498cb33146314084e37dbf2cff3 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 timestamp=1565597765 message_flags=1 channel_flags=0 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index 84d351688..97f76597c 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -200,39 +200,5 @@ The coinbase pays 50 BTC to the following key/address: P2WPKH: bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080 A further 100 blocks are generated to allow the 50BTC output to be -spent, with block 102 containing the following transaction, to allow -funding of channels with whole UTXOs for easy testing: - - 020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833b5c4ab00ccc8a556d042830000000000feffffff0580841e0000000000160014fd9658fbd476d318f3b825b152b152aafa49bc9240420f000000000016001483440596268132e6c99d44dae2d151dabd9a2b2338496d2901000000160014d295f76da2319791f36df5759e45b15d5e105221c0c62d000000000016001454d14ae910793e930d8e33d3de0b0cbf05aa533300093d00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd6024730440220782128cb0319a8430a687c51411e34cfaa6641da9a8f881d8898128cb5c46897022056e82d011a95fd6bcb6d0d4f10332b0b0d1227b2c4ced59e540eb708a4b24e4701210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179865000000 - -Here are the keys to spend funds, derived from BIP32 seed `0000000000000000000000000000000000000000000000000000000000000001`: - - pubkey 0/0/1: 02d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b - privkey 0/0/1: 76edf0c303b9e692da9cb491abedef46ca5b81d32f102eb4648461b239cb0f99 - WIF 0/0/1: cRZtHFwyrV3CS1Muc9k4sXQRDhqA1Usgi8r7NhdEXLgM5CUEZufg - P2WPKH 0/0/1: bcrt1qsdzqt93xsyewdjvagndw9523m27e52er5ca7hm - UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1 (0.01BTC) - - pubkey 0/0/2: 038f1573b4238a986470d250ce87c7a91257b6ba3baf2a0b14380c4e1e532c209d - privkey 0/0/2: bc2f48a76a6b8815940accaf01981d3b6347a68fbe844f81c50ecbadf27cd179 - WIF 0/0/2: cTtWRYC39drNzaANPzDrgoYsMgs5LkfE5USKH9Kr9ySpEEdjYt3E - P2WPKH 0/0/2: bcrt1qlkt93775wmf33uacykc49v2j4tayn0yj25msjn - UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/0 (0.02BTC) - - pubkey 0/0/3: 02ffef0c295cf7ca3a4ceb8208534e61edf44c606e7990287f389f1ea055a1231c - privkey 0/0/3: 16c5027616e940d1e72b4c172557b3b799a93c0582f924441174ea556aadd01c - WIF 0/0/3: cNLxnoJSQDRzXnGPr4ihhy2oQqRBTjdUAM23fHLHbZ2pBsNbqMwb - P2WPKH 0/0/3: bcrt1q2ng546gs0ylfxrvwx0fauzcvhuz655en4kwe2c - UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/3 (0.03BTC) - - pubkey 0/0/4: 026957e53b46df017bd6460681d068e1d23a7b027de398272d0b15f59b78d060a9 - privkey 0/0/4: 53ac43309b75d9b86bef32c5bbc99c500910b64f9ae089667c870c2cc69e17a4 - WIF 0/0/4: cQPMJRjxse9i1jDeCo8H3khUMHYfXYomKbwF5zUqdPrFT6AmtTbd - P2WPKH 0/0/4: bcrt1qrdpwrlrmrnvn535l5eldt64lxm8r2nwkv0ruxq - UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/4 (0.04BTC) - - pubkey 0/0/5: 03a9f795ff2e4c27091f40e8f8277301824d1c3dfa6b0204aa92347314e41b1033 - privkey 0/0/5: 16be98a5d4156f6f3af99205e9bc1395397bca53db967e50427583c94271d27f - WIF 0/0/5: cNLuxyjvR6ga2q6fdmSKxAd1CPQDShKV9yoA7zFKT7GJwZXr9MmT - P2WPKH 0/0/5: bcrt1q622lwmdzxxterumd746eu3d3t40pq53p62zhlz - UTXO: 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/2 (49.89995320BTC) +spent, so block height is 101. The file `setup.incl` contains more +helpers for standard setups. From 46c4139419fe27184c02f408323cf261ae4a6e42 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:19:57 +0930 Subject: [PATCH 072/103] Simple gossip tests, part 1. Signed-off-by: Rusty Russell --- ...lt7-01-channel_announcement-success.events | 110 ++++++++++ ...t7-02-channel_announcement-failures.events | 207 ++++++++++++++++++ 2 files changed, 317 insertions(+) create mode 100644 tests/events/bolt7-01-channel_announcement-success.events create mode 100644 tests/events/bolt7-02-channel_announcement-failures.events diff --git a/tests/events/bolt7-01-channel_announcement-success.events b/tests/events/bolt7-01-channel_announcement-success.events new file mode 100644 index 000000000..b48e64c8a --- /dev/null +++ b/tests/events/bolt7-01-channel_announcement-success.events @@ -0,0 +1,110 @@ +# Simple gossip tests. + +include setup.incl + +1. block: $BLOCK_102 + +2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 +3. expect-send: type=init +4. recv: type=init localfeatures= globalfeatures= + +# Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000010 and 0000000000000000000000000000000000000000000000000000000000000020 +# txid 189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c7560311d +5. block: height=103 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c5410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d8187117382024730440220798d96d5a057b5b7797988a855217f41af05ece3ba8278366e2f69763c72e785022065d5dd7eeddc0766ddf65557c92b9c52c301f23f94d2cf681860d32153e6ae1e012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + +6. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + +# New peer connects, asking for initial_routing_sync. We *won't* relay channel_announcement, as there is no channel_update. +7. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +8. expect-send: type=init +9. recv: type=init localfeatures=08 globalfeatures= +10. must-not-send: type=channel_announcement +11. disconnect: + +12. recv: type=channel_update + signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + timestamp=1565587763 + message_flags=0 + channel_flags=0 + cltv_expiry_delta=144 + htlc_minimum_msat=0 + fee_base_msat=1000 + fee_proportional_millionths=10 + +# Now we'll relay to a new peer. +13. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +14. expect-send: type=init +15. recv: type=init localfeatures=08 globalfeatures= +16. expect-send: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 +17. expect-send: type=channel_update + signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + timestamp=1565587763 + message_flags=0 + channel_flags=0 + cltv_expiry_delta=144 + htlc_minimum_msat=0 + fee_base_msat=1000 + fee_proportional_millionths=10 + +# And it will relay this, too. +18. recv: conn=0000000000000000000000000000000000000000000000000000000000000003 type=channel_update + signature=0b20265c60b98d6150097ea2ed73a0df4c870ed13defde348c799dd418671ca814837b7b46733d3f28f63b4f36768b44f6ec8dc52fbb08103e27c85ab1188c60 + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + timestamp=1565587763 + message_flags=1 + channel_flags=1 + cltv_expiry_delta=48 + htlc_minimum_msat=0 + fee_base_msat=100 + fee_proportional_millionths=11 + htlc_maximum_msat=100000 +19. expect-send: type=channel_update + signature=0b20265c60b98d6150097ea2ed73a0df4c870ed13defde348c799dd418671ca814837b7b46733d3f28f63b4f36768b44f6ec8dc52fbb08103e27c85ab1188c60 + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + timestamp=1565587763 + message_flags=1 + channel_flags=1 + cltv_expiry_delta=48 + htlc_minimum_msat=0 + fee_base_msat=100 + fee_proportional_millionths=11 + htlc_maximum_msat=100000 +20. disconnect: + +# Now, if channel closes, it won't be relayed. + +21. block: height=109 n=1 tx=020000000001011d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c180000000000ffffffff010e410f00000000001600141b42e1fc7b1cd93a469fa67ed5eabf36ce354dd60400483045022100d93a21312af5b9a46041d2189e5b72f593fc865d920f705d76a25a728de5790302207995cc2dd45ff20c96ccea8b117be41581da8b84466dabfeea728ed858a3a7fd0147304402206d9f5e3b2b2540002ffc37815cef3fbc4ba7646a7bca1aa7605941edd735dee802205130da104d584df6b59c18704c94cd4edd032aed7e0c3044dc8815183552f2dd0147522103d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e652103e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a52ae00000000 + +22. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +23. expect-send: type=init +24. recv: type=init localfeatures=08 globalfeatures= +25. must-not-send: type=channel_announcement +26. must-not-send: type=channel_update diff --git a/tests/events/bolt7-02-channel_announcement-failures.events b/tests/events/bolt7-02-channel_announcement-failures.events new file mode 100644 index 000000000..0fc8a12fa --- /dev/null +++ b/tests/events/bolt7-02-channel_announcement-failures.events @@ -0,0 +1,207 @@ +# Tests for malformed/bad channel_announcement +include setup.incl + +1. block: $BLOCK_102 + +2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 +3. expect-send: type=init +4. recv: type=init localfeatures= globalfeatures= + +# Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000010 and 0000000000000000000000000000000000000000000000000000000000000020 +# txid 189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c7560311d +5. block: height=103 n=1 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c5410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d8187117382024730440220798d96d5a057b5b7797988a855217f41af05ece3ba8278366e2f69763c72e785022065d5dd7eeddc0766ddf65557c92b9c52c301f23f94d2cf681860d32153e6ae1e012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 + + # Invalid `channel_announcement`: short_channel_id too young. + # It's allowed (even encouraged!) to cache this, so we separate this + # from the other tests. + 1. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + + # Invalid `channel_announcement`: short_channel_id *still* too young. + 1. block: height=104 n=4 + 2. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + + # This makes announcement otherwise acceptable. + 1. block: height=104 n=5 + + # Invalid `channel_announcement`: bad node_signature_1. + 1. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f62 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + 2. expect-error: + + # Invalid `channel_announcement`: bad node_signature_2. + 1. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98f + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + 2. expect-error: + + # Invalid `channel_announcement`: bad bitcoin_signature_1. + 1. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc38 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + 2. expect-error: + + # Invalid `channel_announcement`: bad bitcoin_signature_2. + 1. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa13 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + 2. expect-error: + + # Ignored `channel_announcement`: bad chain_hash + 1. recv: type=channel_announcement + node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 + node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e + bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 + bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf1889100 + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + + # Invalid `channel_announcement`: short_channel_id DNE + 1. recv: type=channel_announcement + node_signature_1=69d878cc06a2444a92244534aa2a106b2a8270299f20d15a693d2416fa60fb8535342929dfb17fcfcd4f800692d16994861037333a5f9503b3eaf1091acd18b4 + node_signature_2=dc678146f6f55db9d0751e24a045c1ce080aa973c1af9fbec7e2f088bb4eef322b746bb9cfcd3fddbf3b27f0b55517bc3f7e32d25652f51b7f1f7ca86d439b3b + bitcoin_signature_1=d0dca329a8705c92b7aa18f5d42731c31d17a0a0cd104c8e012c9c1f763f4f9857eba89b41264669c64be7316e38cd6c62a23bddb9db25773f28f421220339e4 + bitcoin_signature_2=f8cc9ac5c9147c3077b60f7768403a3f251d421672de0867e6c0314074679d373e9038be8253ae3668586e7cedc50f347725c2296274b7e8e9e26efee9374513 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x5x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + + # Invalid `channel_announcement`: short_channel_id output DNE + 1. recv: type=channel_announcement + node_signature_1=ff3d3d3cf42b2a967b51407d0097fb5bb5035117726ddc16de9758cc1d11d87e65e468e5554b8d69ee2cd3ece701c75417f9a70c7dbd4139732aff0daba31ce4 + node_signature_2=5f709cca17429766bc7057c37d24b3820cc8541ae347b157ca693902b94729d6221000c776011cf427fdf7fff870262cadb4ed91fd44ee1fd7b2e5323d74ba17 + bitcoin_signature_1=0ab5cc881ac52e0e3644831c0a0da7a18c94a2cc51e09b637ba6cff3bedfba8146be0d666a6b82f374bedc682a75491303dd286773b68d97f523df3169cf16b2 + bitcoin_signature_2=9990fd49c489b880bf305fc56946356557c78cb306e915706b4ee02d8eec60497a322018f0e7b1896996860e304a82b3f27ea24038e63c05eb0e8fa1699dabb8 + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x1 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + + # Invalid `channel_announcement`: short_channel_id tx does not match + # (second bitcoin privkey is ...021 instead of ...020) + 1. recv: type=channel_announcement + node_signature_1=97eaa79c72eca400466390454cfaae9805e3e827a396e9f0d91c6abd0371f8136252dad20b56258a4955f78e9e76d063ec9cace9ac0735879fe60620f7502bc9 + node_signature_2=f1c432187bf0cf6629c7c99397f92153960630d2d766a2b59816c34c6a677a121414c20bf9dda865248112248fb0b017020e3676d6ebc6485c4056d55879d829 + bitcoin_signature_1=387ccb63e1dca46f1926de5b963500982eabe9a375d755a804ced67a3977253a2a3bbd525fa0de438b7dc39ec4939a7d81d9c832725005dca77c8fd4ac1dbfa0 + bitcoin_signature_2=0ea3ba77c7644cf34446f1c957cc95f9d2a6aa1abc939e4daddb180e3aa1b01f6c4613cbc9290cdbef74bbdd6a61da58e4ade784edc47795bab4514850f92fce + features= + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 + node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 + bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + bitcoin_key_2=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 + +# To test if it accepted one of those channel_announcements, give it +# the matching channel_update, which should make it broadcast. +6. connect: privkey=0000000000000000000000000000000000000000000000000000000000000004 +7. recv: type=channel_update + signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x0 + timestamp=1565587763 + message_flags=0 + channel_flags=0 + cltv_expiry_delta=144 + htlc_minimum_msat=0 + fee_base_msat=1000 + fee_proportional_millionths=10 +8. recv: type=channel_update + signature=b236ed64ff6511baabba2b932e30da95e38c3d533e13870a96bb43150eb86a1453b00da41a5fc1ed5ae20f92c56812b40864996219b1e31188ae40e107e6140d + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x1x1 + timestamp=1565587763 + message_flags=0 + channel_flags=0 + cltv_expiry_delta=144 + htlc_minimum_msat=0 + fee_base_msat=1000 + fee_proportional_millionths=10 +9. recv: type=channel_update + signature=0bff9ee3b8e6ef8670b39817c21b9a6cc172ec47f0ea6b4aa4ae2469c3c352267969a0bc70cbdd441fb6f7e305b61cac6d1f16d5e042f8b72742c1d2c9a35e90 + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + short_channel_id=103x5x0 + timestamp=1565587763 + message_flags=0 + channel_flags=0 + cltv_expiry_delta=144 + htlc_minimum_msat=0 + fee_base_msat=1000 + fee_proportional_millionths=10 + +# New peer connects, asking for initial_routing_sync. We *won't* relay channel_announcement. +10. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +11. expect-send: type=init +12. recv: type=init localfeatures=08 globalfeatures= +13. must-not-send: type=channel_announcement +14. must-not-send: type=channel_update From 7e39c2ce5b7e200c11a870d959130b775d539e93 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:19:57 +0930 Subject: [PATCH 073/103] Basic gossip_timestamp_filter tests. Signed-off-by: Rusty Russell --- .../bolt7-10-gossip_timestamp_filter.events | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 tests/events/bolt7-10-gossip_timestamp_filter.events diff --git a/tests/events/bolt7-10-gossip_timestamp_filter.events b/tests/events/bolt7-10-gossip_timestamp_filter.events new file mode 100644 index 000000000..bb25211cd --- /dev/null +++ b/tests/events/bolt7-10-gossip_timestamp_filter.events @@ -0,0 +1,135 @@ +# Tests for gossip_timestamp_filter. + +# Variables for some standard gossiping messages. +include setup.incl +1. block: $BLOCK_102 + +2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 +3. expect-send: type=init +4. recv: type=init localfeatures= globalfeatures= + +5. block: $BLOCK_103 + +6. recv: $CHAN_ANN_103x1x0 +7. recv: $NODE_ANN_002 + +# New peer connects, asks for gossip_timestamp_filter=all. We *won't* relay channel_announcement, as there is no channel_update. +8. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +9. expect-send: type=init +10. recv: type=init localfeatures= globalfeatures= +11. recv: type=gossip_timestamp_filter + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + first_timestamp=0 + timestamp_range=4294967295 +12. must-not-send: type=channel_announcement +13. must-not-send: type=node_announcement +14. disconnect: + +15. recv: $CHAN_UPDATE_103x1x0_002 + +# New peer connects, asks for gossip_timestamp_filter=all. update and node announcement will be relayed. +16. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +17. expect-send: type=init +18. recv: type=init localfeatures= globalfeatures= +19. recv: type=gossip_timestamp_filter + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + first_timestamp=0 + timestamp_range=4294967295 +20. expect-send: $CHAN_ANN_103x1x0 +21. Any order: + 1. expect-send: $CHAN_UPDATE_103x1x0_002 + 1. expect-send: $NODE_ANN_002 +22. disconnect: + +# BOLT 7: +# The receiver: +# - SHOULD send all gossip messages whose `timestamp` is greater or +# equal to `first_timestamp`, and less than `first_timestamp` plus +# `timestamp_range`. + +23. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +24. expect-send: type=init +25. recv: type=init localfeatures= globalfeatures= +26. recv: type=gossip_timestamp_filter + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + first_timestamp=1000 + timestamp_range=1565586763 +27. must-not-send: type=channel_announcement +28. must-not-send: type=channel_update +29. must-not-send: type=node_announcement +30. disconnect: + +31. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +32. expect-send: type=init +33. recv: type=init localfeatures= globalfeatures= +34. recv: type=gossip_timestamp_filter + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + first_timestamp=1565587764 + timestamp_range=4294967295 +35. must-not-send: type=channel_announcement +36. must-not-send: type=channel_update +37. must-not-send: type=node_announcement +38. disconnect: + +# These two succeed in getting the gossip, then stay connected for next test. +39. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +40. expect-send: type=init +41. recv: type=init localfeatures= globalfeatures= +42. recv: type=gossip_timestamp_filter + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + first_timestamp=1565587763 + timestamp_range=4294967295 +43. expect-send: $CHAN_ANN_103x1x0 +44. Any order: + 1. expect-send: $CHAN_UPDATE_103x1x0_002 + 1. expect-send: $NODE_ANN_002 + +45. connect: privkey=0000000000000000000000000000000000000000000000000000000000000006 +46. expect-send: type=init +47. recv: type=init localfeatures= globalfeatures= +48. recv: type=gossip_timestamp_filter + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + first_timestamp=1000 + timestamp_range=1565586764 +49. expect-send: $CHAN_ANN_103x1x0 +50. Any order: + 1. expect-send: $CHAN_UPDATE_103x1x0_002 + 1. expect-send: $NODE_ANN_002 + +# BOLT 7: +# - SHOULD restrict future gossip messages to those whose `timestamp` +# is greater or equal to `first_timestamp`, and less than +# `first_timestamp` plus `timestamp_range`. + +51. block: $BLOCK_109 + +52. recv: conn=0000000000000000000000000000000000000000000000000000000000000003 + $CHAN_ANN_109x1x0 + +53. recv: conn=0000000000000000000000000000000000000000000000000000000000000003 + $CHAN_UPDATE_109x1x0_004 + +54. recv: conn=0000000000000000000000000000000000000000000000000000000000000003 + $CHAN_UPDATE_109x1x0_005 + +55. recv: conn=0000000000000000000000000000000000000000000000000000000000000003 + $NODE_ANN_004 + +# 005's filter covers this, 006's doesn't. +56. expect-send: conn=0000000000000000000000000000000000000000000000000000000000000005 + $CHAN_ANN_109x1x0 + +57. Any order: + 1. expect-send: conn=0000000000000000000000000000000000000000000000000000000000000005 + $CHAN_UPDATE_109x1x0_004 + 1. expect-send: conn=0000000000000000000000000000000000000000000000000000000000000005 + $CHAN_UPDATE_109x1x0_005 + 1. expect-send: conn=0000000000000000000000000000000000000000000000000000000000000005 + $NODE_ANN_004 + +58. must-not-send: conn=0000000000000000000000000000000000000000000000000000000000000006 + type=channel_announcement +59. must-not-send: conn=0000000000000000000000000000000000000000000000000000000000000006 + type=channel_update +60. must-not-send: conn=0000000000000000000000000000000000000000000000000000000000000006 + type=node_announcement From 4f3fe68ef7b559603fe7b8f2c91cf4acd49ff2c7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:21:26 +0930 Subject: [PATCH 074/103] Basic query_channel_range tests. Signed-off-by: Rusty Russell --- .../bolt7-20-query_channel_range.events | 68 +++++++++++++++++++ tools/test-events-clightning.py | 2 + 2 files changed, 70 insertions(+) create mode 100644 tests/events/bolt7-20-query_channel_range.events diff --git a/tests/events/bolt7-20-query_channel_range.events b/tests/events/bolt7-20-query_channel_range.events new file mode 100644 index 000000000..c36c9fdd7 --- /dev/null +++ b/tests/events/bolt7-20-query_channel_range.events @@ -0,0 +1,68 @@ +# Tests for query_channel_range. + +# Note for gossip_channel_range: we are *allowed* to return a superset +# of what they ask, so if someone does that this test must be modified +# to accept it (add an option_IMPL_gossip_query_superset). +# +# Meanwhile, we assume an exact reply. + +include setup.incl +1. block: $BLOCK_102 + +# Our two channels. +2. block: $BLOCK_103 +3. block: $BLOCK_109 + +4. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 +5. expect-send: type=init +6. recv: type=init localfeatures= globalfeatures= +# They can send this, we'll ignore it. +7. maybe-send: type=gossip_timestamp_filter + +# Channel 103x1x0 (between 002 and 003) +8. recv: $CHAN_ANN_103x1x0 +9. recv: $CHAN_UPDATE_103x1x0_002 + +# Channel 109x1x0 (between 004 and 005) +10. recv: $CHAN_ANN_109x1x0 +11. recv: $CHAN_UPDATE_109x1x0_005 +12. recv: $CHAN_UPDATE_109x1x0_004 + +# New peer connects, with gossip_query option. +13. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +14. expect-send: type=init +15. recv: type=init localfeatures=80 globalfeatures= +16. maybe-send: type=gossip_timestamp_filter + + # No queries? Must not get anything. + 1. must-not-send: type=channel_announcement + 2. must-not-send: type=channel_update + 3. must-not-send: type=node_announcement + + # This should elicit an empty response (we assume no zlib for that!) + 1. recv: type=query_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=0 number_of_blocks=103 option_gossip_queries + 2. One of: option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=0 number_of_blocks=103 encoded_short_ids=00 option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=0 number_of_blocks=103 encoded_short_ids=01789c030000000001 option_gossip_queries + + # This should get the first one, not the second. + 1. recv: type=query_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=1 option_gossip_queries + 2. One of: option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=1 encoded_short_ids=000000670000010000 option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=1 encoded_short_ids=01789c6360486760606460000002750069 option_gossip_queries + + # This should get the second one, not the first. + 1. recv: type=query_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=109 number_of_blocks=4294967295 option_gossip_queries + 2. One of: option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=109 number_of_blocks=4294967295 encoded_short_ids=0000006d0000010000 option_gossip_queries + # Could truncate number_of_blocks. + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=109 number_of_blocks=4294967187 encoded_short_ids=0000006d0000010000 option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=109 number_of_blocks=4294967295 encoded_short_ids=01789c6360c8656060646000000299006f option_gossip_queries + # Could truncate number_of_blocks. + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=109 number_of_blocks=4294967187 encoded_short_ids=01789c6360c8656060646000000299006f option_gossip_queries + + # This should get both. + 1. recv: type=query_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 option_gossip_queries + 2. One of: option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 option_gossip_queries diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 5418ac82f..7e2b8f744 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -191,6 +191,8 @@ def restart(self): self.start() def connect(self, conn, line): + # FIXME: This serves to settle the gossip, eg tests/events/bolt7-20-query_channel_range.events fails without this. + time.sleep(1) # FIXME: Open-code the lightning enc protocol in Python! conn.proc = subprocess.Popen(['{}/devtools/gossipwith'.format(LIGHTNING_SRC), '--privkey={}'.format(conn.connkey), From 0fab8a6a442d74896f4704858ca844c0a8c838f1 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:22:20 +0930 Subject: [PATCH 075/103] basic query_short_channel_ids tests. Signed-off-by: Rusty Russell --- .../bolt7-25-query_short_channel_ids.events | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/events/bolt7-25-query_short_channel_ids.events diff --git a/tests/events/bolt7-25-query_short_channel_ids.events b/tests/events/bolt7-25-query_short_channel_ids.events new file mode 100644 index 000000000..30a4f41ba --- /dev/null +++ b/tests/events/bolt7-25-query_short_channel_ids.events @@ -0,0 +1,76 @@ +# Tests for query_short_channel_ids. + +include setup.incl +1. block: $BLOCK_102 + +# Our three channels, and four nodes. +2. block: $BLOCK_103 +3. block: $BLOCK_109 +4. block: $BLOCK_115 + +5. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 +6. expect-send: type=init +7. recv: type=init localfeatures= globalfeatures= +# They can send this, we'll ignore it. +8. maybe-send: type=gossip_timestamp_filter + +# Channel 103x1x0 (between 002 and 003), only one update, both node_announce +9. recv: $CHAN_ANN_103x1x0 +10. recv: $CHAN_UPDATE_103x1x0_002 +11. recv: $NODE_ANN_002 +12. recv: $NODE_ANN_003 + +# Channel 109x1x0 (between 004 and 005): both updates, only one node_announce +13. recv: $CHAN_ANN_109x1x0 +# Node-announce first is legal +14. recv: $NODE_ANN_004 +15. recv: $CHAN_UPDATE_109x1x0_004 +16. recv: $CHAN_UPDATE_109x1x0_005 + +# Channel 115x1x0 (between 003 and 004): no updates. +17. recv: $CHAN_ANN_115x1x0 + +# New peer connects, with gossip_query option. +18. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 +19. expect-send: type=init +20. recv: type=init localfeatures=80 globalfeatures= +21. maybe-send: type=gossip_timestamp_filter + +# Query for non-existent channels (104x1x0 105x1x0 106x1x0 107x1x0) +22. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=000000680000010000000069000001000000006a000001000000006b0000010000 +23. expect-send: type=reply_short_channel_ids_end + +# zlib version +24. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=01789c6360c86060606400824c289d05a5b3c134001de001ab +25. expect-send: type=reply_short_channel_ids_end + +# Query for one channel (103x1x0) +26. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=000000670000010000 +27. expect-send: $CHAN_ANN_103x1x0 +28. Any order: + 1. expect-send: $CHAN_UPDATE_103x1x0_002 + 1. expect-send: $NODE_ANN_002 + 1. expect-send: $NODE_ANN_003 +29. expect-send: type=reply_short_channel_ids_end + +# Query for two channels (103x1x0 109x1x0) +30. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 +31. One of: # the channel_announcements must lead, then it gets messy. + 1. expect-send: $CHAN_ANN_103x1x0 + 2. Any order: # Not really *any* order, since ann must predate update. + 1. expect-send: $CHAN_UPDATE_103x1x0_002 + 1. expect-send: $NODE_ANN_002 + 1. expect-send: $NODE_ANN_003 + 1. expect-send: $CHAN_ANN_109x1x0 + 1. expect-send: $CHAN_UPDATE_109x1x0_004 + 1. expect-send: $CHAN_UPDATE_109x1x0_005 + 1. expect-send: $NODE_ANN_004 + 1. expect-send: $CHAN_ANN_109x1x0 + 2. Any order: + 1. expect-send: $CHAN_ANN_103x1x0 + 1. expect-send: $CHAN_UPDATE_103x1x0_002 + 1. expect-send: $NODE_ANN_002 + 1. expect-send: $NODE_ANN_003 + 1. expect-send: $CHAN_UPDATE_109x1x0_004 + 1. expect-send: $CHAN_UPDATE_109x1x0_005 + 1. expect-send: $NODE_ANN_004 From 841a4a42b0942426466a0a724709d51e83dcad5b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:23:46 +0930 Subject: [PATCH 076/103] query_short_channel_ids tests for option_gossip_queries_ex. Signed-off-by: Rusty Russell --- .../bolt7-25-query_short_channel_ids.events | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/events/bolt7-25-query_short_channel_ids.events b/tests/events/bolt7-25-query_short_channel_ids.events index 30a4f41ba..8efdbdf61 100644 --- a/tests/events/bolt7-25-query_short_channel_ids.events +++ b/tests/events/bolt7-25-query_short_channel_ids.events @@ -74,3 +74,51 @@ include setup.incl 1. expect-send: $CHAN_UPDATE_109x1x0_004 1. expect-send: $CHAN_UPDATE_109x1x0_005 1. expect-send: $NODE_ANN_004 +32. expect-send: type=reply_short_channel_ids_end + +# Query for specific things only, if supported. + +# Announce messages only. + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=0103000101 option_gossip_queries_ex + # zlib-encoded variant + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=010b01789c6364040000050003 option_gossip_queries_ex +33. Any order: option_gossip_queries_ex + 1. expect-send: $CHAN_ANN_103x1x0 option_gossip_queries_ex + 1. expect-send: $CHAN_ANN_109x1x0 option_gossip_queries_ex +34. expect-send: type=reply_short_channel_ids_end option_gossip_queries_ex + +# Node 1 channel_update messages only. + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=0103000202 option_gossip_queries_ex + # zlib-encoded variant + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=010b01789c6362020000080005 option_gossip_queries_ex + +35. Any order: option_gossip_queries_ex + 1. expect-send: $CHAN_UPDATE_103x1x0_002 option_gossip_queries_ex + 1. expect-send: $CHAN_UPDATE_109x1x0_005 option_gossip_queries_ex +36. expect-send: type=reply_short_channel_ids_end option_gossip_queries_ex + +# Node 2 channel_update messages only. + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=0103000404 option_gossip_queries_ex + # zlib-encoded variant + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=010b01789c63610100000e0009 option_gossip_queries_ex + +37. expect-send: $CHAN_UPDATE_109x1x0_004 option_gossip_queries_ex +38. expect-send: type=reply_short_channel_ids_end option_gossip_queries_ex + +# Node 1 announcements only. + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=0103000808 option_gossip_queries_ex + # zlib-encoded variant + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=010b01789ce3e00000001a0011 option_gossip_queries_ex + +39. expect-send: $NODE_ANN_002 option_gossip_queries_ex +40. expect-send: type=reply_short_channel_ids_end option_gossip_queries_ex + +# Node 2 announcements only. + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=0103001010 option_gossip_queries_ex + # zlib-encoded variant + 1. recv: type=query_short_channel_ids chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f encoded_short_ids=00000067000001000000006d0000010000 tlvs=010b01789c1310000000320021 option_gossip_queries_ex + +41. Any order: option_gossip_queries_ex + 1. expect-send: $NODE_ANN_003 option_gossip_queries_ex + 1. expect-send: $NODE_ANN_004 option_gossip_queries_ex +42. expect-send: type=reply_short_channel_ids_end option_gossip_queries_ex From fabde2bd863a42c914c6e8864243b64aabb58b81 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 13:24:14 +0930 Subject: [PATCH 077/103] query_channel_range tests for option_gossip_queries_ex --- .../bolt7-20-query_channel_range.events | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/events/bolt7-20-query_channel_range.events b/tests/events/bolt7-20-query_channel_range.events index c36c9fdd7..bb876d5e5 100644 --- a/tests/events/bolt7-20-query_channel_range.events +++ b/tests/events/bolt7-20-query_channel_range.events @@ -66,3 +66,33 @@ include setup.incl 2. One of: option_gossip_queries 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 option_gossip_queries 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 option_gossip_queries + + # This should get appended timestamp fields with option_gossip_queries_ex + 1. recv: type=query_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 tlvs=010101 option_gossip_queries + 2. One of: option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 option_gossip_queries !option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 option_gossip_queries !option_gossip_queries_ex + # Timestamps may or may not be zlib encoded. + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 tlvs=0111005d50f933000000005d50f9355d50f934 option_gossip_queries option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 tlvs=011601789c8b0df869cc0004b1013f4d81d804002b46058f option_gossip_queries option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 tlvs=011601789c8b0df869cc0004b1013f4d81d804002b46058f option_gossip_queries option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 tlvs=011601789c8b0df869cc0004b1013f4d81d804002b46058f option_gossip_queries option_gossip_queries_ex option_gossip_queries option_gossip_queries_ex + + # This should get appended checksum fields with option_gossip_queries_ex + 1. recv: type=query_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 tlvs=010102 option_gossip_queries + 2. One of: option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 option_gossip_queries !option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 option_gossip_queries !option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 tlvs=03101112fa3000000000f32ce9689bece840 option_gossip_queries option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 tlvs=03101112fa3000000000f32ce9689bece840 option_gossip_queries option_gossip_queries_ex + + # This should append timestamps and checksums with option_gossip_queries_ex + 1. recv: type=query_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 tlvs=010103 option_gossip_queries + 2. One of: option_gossip_queries + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 option_gossip_queries !option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 option_gossip_queries !option_gossip_queries_ex + # Timestamps may or may not be zlib encoded. + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 tlvs=0111005d50f933000000005d50f9355d50f93403101112fa3000000000f32ce9689bece840 option_gossip_queries option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=00000067000001000000006d0000010000 tlvs=011601789c8b0df869cc0004b1013f4d81d804002b46058f03101112fa3000000000f32ce9689bece840 option_gossip_queries option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 tlvs=0111005d50f933000000005d50f9355d50f93403101112fa3000000000f32ce9689bece840 option_gossip_queries option_gossip_queries_ex + 1. expect-send: type=reply_channel_range chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_blocknum=103 number_of_blocks=7 encoded_short_ids=01789c6360486760606400825c300d00084e00d7 tlvs=011601789c8b0df869cc0004b1013f4d81d804002b46058f03101112fa3000000000f32ce9689bece840 option_gossip_queries option_gossip_queries_ex From fd408dca198bf3608917b721d6d6c0cdb34b0e5c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 29 Aug 2019 16:02:57 +0930 Subject: [PATCH 078/103] tests: add tests for option_static_remotekey. Signed-off-by: Rusty Russell --- tests/events/bolt1-01-init.events | 17 ++++ tests/events/bolt2-02-add-htlc.events | 112 ++++++++++++++++------ tests/events/bolt2-03-htlc-fail.events | 71 +++++++++----- tests/events/bolt2-04-htlc-fulfill.events | 85 ++++++++++++---- 4 files changed, 214 insertions(+), 71 deletions(-) diff --git a/tests/events/bolt1-01-init.events b/tests/events/bolt1-01-init.events index 78b3ec0f3..57b605fe4 100644 --- a/tests/events/bolt1-01-init.events +++ b/tests/events/bolt1-01-init.events @@ -56,6 +56,23 @@ EXPECT_INIT=expect-send: type=init # If you require `option_data_loss_protect`, you will advertize it even. 1. $EXPECT_INIT localfeatures=01/03 option_data_loss_protect/even + # If you don't support `option_static_remotekey`, you will be ok if + # we ask for it. + 1. $EXPECT_INIT localfeatures=0000000000/C000000000 !option_static_remotekey + 2. recv: type=init globalfeatures= localfeatures=02000000000000 !option_static_remotekey + + # If you don't support `option_static_remotekey`, you will error if + # we require it. + 1. $EXPECT_INIT localfeatures=0000000000/C000000000 !option_static_remotekey + 2. recv: type=init globalfeatures= localfeatures=01000000000000 !option_static_remotekey + 3. expect-error: !option_static_remotekey + + # If you support `option_static_remotekey`, you will advertize it odd. + 1. $EXPECT_INIT localfeatures=02000000000000/03000000000000 option_static_remotekey/odd + + # If you require `option_static_remotekey`, you will advertize it even. + 1. $EXPECT_INIT localfeatures=01000000000000/03000000000000 option_static_remotekey/even + # Note: it's undefined what you'll do if implementation requires # an option and isn't offered it. The recipient of the required feature # bit should notice the requirement and error. diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index 9c40c0119..c40efd411 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -18,7 +18,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures=02 +4. recv: type=init globalfeatures= localfeatures=02000000000002 5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -72,8 +72,10 @@ include setup.incl # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 funding_output_index=0 - # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 - signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + # !option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 + signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a !option_static_remotekey + # option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74cff0020 + signature=02ce278a17c48e926f93d5134e8f7486e01112a7d06c2ed1b1b5034fb9ace8072d1485ee012440fc85b46cf671a802db4597d482ced68dbfa26ee07b899e936a option_static_remotekey 8. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -102,19 +104,24 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init + # Note: if we opened channel with option_static_remotekey, it stands even + # if we don't negotiate it again! 4. recv: type=init globalfeatures= localfeatures=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # BOLT #2: # - if `next_commitment_number` is 1 in both the @@ -155,13 +162,16 @@ include setup.incl next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -178,7 +188,8 @@ include setup.incl 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c + signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c !option_static_remotekey + signature=05f85dd6f09a5004f11140b2da5b7c1e2debfd84232b04943b26a10da4f30856670e670e6618629f95d3b76f0167a9d906f92f2023884c8b24354b78be8b6fb8 option_static_remotekey htlc_signature= 3. expect-send: type=revoke_and_ack @@ -208,13 +219,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # - MUST re-send the `revoke_and_ack`. 8. expect-send: type=revoke_and_ack @@ -237,13 +251,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -260,13 +277,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 5. recv: type=revoke_and_ack @@ -291,13 +311,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Add a non-dust HTLC @@ -326,13 +349,16 @@ include setup.incl next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=funding_locked channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -349,8 +375,24 @@ include setup.incl 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd - htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 + # !option_static_remotekey: + ## remote_commitment + # input amount 999878sat, funding_wscript 522103d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e652103e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a52ae, key 03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # unsigned remote commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e8030000000000002200204a7ee4c37da8a8ab48e53517c27173098a61f794d2adb84faf0c86ec0c18385ffc3c0f0000000000160014ded1a6b285067b547db1d27bc87d32b84ac949cc4dff0020 + ## Output 0: LOCAL HTLC 0 + # unsigned htlc tx for output 0: 0200000001d3617e206fcf3d62ccaf0328e6ef88b9936afde335552e720226447eb4afffcc000000000000000000013703000000000000220020c950c75b39235322de605f8d8ff7533edf8cfa4e5edd090425c326cfbf4d216700000000 + # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 + signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd !option_static_remotekey + htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 !option_static_remotekey + # option_static_remotekey: + ## remote_commitment + # input amount 999878sat, funding_wscript 522103d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e652103e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a52ae, key 03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # unsigned remote commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e8030000000000002200204a7ee4c37da8a8ab48e53517c27173098a61f794d2adb84faf0c86ec0c18385ffc3c0f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74dff0020 + # Output 0: LOCAL HTLC 0 + # unsigned htlc tx for output 0: 0200000001a366eac6a4f4aad69c3b292d275f1122e34aa97d091ae808422ef4b6d7599c5f000000000000000000013703000000000000220020cdd8da56037931fe7395cbe19893316feb98077ee1acb1b62f31ef850201f29000000000 + # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 + signature=69de461fb50707921427c8b204a15188820e21f4711fb72548794ecd036ab8ae1e38461426174f856ec9339f4ad827db42f940f87f916d8e0634521479d1521a option_static_remotekey + htlc_signature=3b04f576ccd0c35ad3fae12434f65a9d04bfe5d185a8ddb3a7afe7fef5a2316842c2e7a201474aaa7272b47db216711986b89adadf93f2fffba7613692c10c7d option_static_remotekey 3. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -360,6 +402,8 @@ include setup.incl 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 + # Note: because we only have to-self output, signatures don't change + # with option_static_remotekey signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 @@ -379,13 +423,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # - MUST re-send the `revoke_and_ack`. 8. expect-send: type=revoke_and_ack @@ -408,13 +455,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -431,13 +481,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 5. recv: type=revoke_and_ack @@ -462,11 +515,14 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events index bd98916e4..d9a6fe5a1 100644 --- a/tests/events/bolt2-03-htlc-fail.events +++ b/tests/events/bolt2-03-htlc-fail.events @@ -18,7 +18,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures=02 +4. recv: type=init globalfeatures= localfeatures=02000000000002 5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -72,8 +72,10 @@ include setup.incl # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 funding_output_index=0 - # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 - signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + # !option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 + signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a !option_static_remotekey + # option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74cff0020 + signature=02ce278a17c48e926f93d5134e8f7486e01112a7d06c2ed1b1b5034fb9ace8072d1485ee012440fc85b46cf671a802db4597d482ced68dbfa26ee07b899e936a option_static_remotekey 8. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -106,7 +108,8 @@ include setup.incl 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c + signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c !option_static_remotekey + signature=05f85dd6f09a5004f11140b2da5b7c1e2debfd84232b04943b26a10da4f30856670e670e6618629f95d3b76f0167a9d906f92f2023884c8b24354b78be8b6fb8 option_static_remotekey htlc_signature= 3. expect-send: type=revoke_and_ack @@ -139,13 +142,15 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Add a non-dust HTLC @@ -161,8 +166,10 @@ include setup.incl 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd - htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 + signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd !option_static_remotekey + htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 !option_static_remotekey + signature=69de461fb50707921427c8b204a15188820e21f4711fb72548794ecd036ab8ae1e38461426174f856ec9339f4ad827db42f940f87f916d8e0634521479d1521a option_static_remotekey + htlc_signature=3b04f576ccd0c35ad3fae12434f65a9d04bfe5d185a8ddb3a7afe7fef5a2316842c2e7a201474aaa7272b47db216711986b89adadf93f2fffba7613692c10c7d option_static_remotekey 3. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -194,7 +201,8 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -225,13 +233,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Now it will re-transmit 8. expect-send: type=update_fail_htlc @@ -259,13 +270,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Now it will re-transmit 8. expect-send: type=update_fail_htlc @@ -286,13 +300,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 15. recv: type=revoke_and_ack @@ -317,18 +334,22 @@ include setup.incl next_commitment_number=2 next_revocation_number=2 your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 16. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 + signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 !option_static_remotekey + signature=f1147918abcc66b802756ed8980bf6432e334e1217a9a7aeb2442e95677e66953beb5c6fe468589481b7e0323b8e5560ea2e675462f8e28bbcad38b50a3ed1e0 option_static_remotekey htlc_signature= 17. expect-send: type=revoke_and_ack @@ -353,13 +374,16 @@ include setup.incl next_commitment_number=3 next_revocation_number=2 your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect - my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # tester *has* received revoke_and_ack @@ -372,11 +396,14 @@ include setup.incl next_commitment_number=3 next_revocation_number=2 your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect - my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=2 your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index a24a7708d..689148743 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -22,7 +22,7 @@ include setup.incl 4. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 5. expect-send: type=init -6. recv: type=init globalfeatures= localfeatures=02 +6. recv: type=init globalfeatures= localfeatures=02000000000002 7. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -75,8 +75,10 @@ include setup.incl # txid=41085b995c1f591cfc3ae79ccde012bf0b37c7bde23d80a61c9732bdd6210b2f funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 funding_output_index=0 - # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 - signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + # !option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 + signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a !option_static_remotekey + # option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74cff0020 + signature=02ce278a17c48e926f93d5134e8f7486e01112a7d06c2ed1b1b5034fb9ace8072d1485ee012440fc85b46cf671a802db4597d482ced68dbfa26ee07b899e936a option_static_remotekey 10. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -119,9 +121,25 @@ include setup.incl 17. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=bc5e1b465773cfe59478c5db35e9f9d27bf832436d0ed0c19833b5e7d444e9f26e3522883a110d71e715471727e3ea7703eba0e6e9855e8d59bc0bf93029bb29 - htlc_signature=8ef6bc3d35a91a00cd1edb0a22e5ca7204b297d41cd7c4cdb1c4167d2d298d907e23b9dc75356ff2fee9ced4abc9fba796a90a2939df45080d12c7bbadbda8d8 - + # !option_static_remotekey: + ## remote_commitment + # input amount 999878sat, funding_wscript 522103d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e652103e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a52ae, key 03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # unsigned remote commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e80300000000000022002061a5a700a99098d0c53f5d58b0c4f041ab861467b4eb5841a9d80ba300daf8dafb3c0f0000000000160014ded1a6b285067b547db1d27bc87d32b84ac949cc4dff0020 + ## Output 0: LOCAL HTLC 1 + # unsigned htlc tx for output 0: 02000000014e7c13514515d6baba93a001522446dcb1fbcd73d759b647c9b835cb6c3800c2000000000000000000013703000000000000220020cdd8da56037931fe7395cbe19893316feb98077ee1acb1b62f31ef850201f29000000000 + # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a9148139a4b000a75011a6f624005c9482c04160d94588527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 + signature=bc5e1b465773cfe59478c5db35e9f9d27bf832436d0ed0c19833b5e7d444e9f26e3522883a110d71e715471727e3ea7703eba0e6e9855e8d59bc0bf93029bb29 !option_static_remotekey + htlc_signature=8ef6bc3d35a91a00cd1edb0a22e5ca7204b297d41cd7c4cdb1c4167d2d298d907e23b9dc75356ff2fee9ced4abc9fba796a90a2939df45080d12c7bbadbda8d8 !option_static_remotekey + # option_static_remotekey: + ## remote_commitment + # input amount 999878sat, funding_wscript 522103d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e652103e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a52ae, key 03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # unsigned remote commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e80300000000000022002061a5a700a99098d0c53f5d58b0c4f041ab861467b4eb5841a9d80ba300daf8dafb3c0f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74dff0020 + ## Output 0: LOCAL HTLC 1 + # unsigned htlc tx for output 0: 020000000162b2ce7a192e54c942c3abca50c0535cb60990f08480c7fbb02cf66d641d6f23000000000000000000013703000000000000220020cdd8da56037931fe7395cbe19893316feb98077ee1acb1b62f31ef850201f29000000000 + # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a9148139a4b000a75011a6f624005c9482c04160d94588527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 + signature=aafcc497d0b8e0c7e7593b6447408a058c321a81927153201a981ffa064ba12a761a6d34aedb35450208149f746167bc57026176536c548d7c8b40343bf65a36 option_static_remotekey + htlc_signature=eabc09f68e9195c2097060a5c8e4c1fa692afcf6c52c24ef4db775e299a028fb65445f591fc94f66172b94a2cabb1be4c0b95bd1cf14935cf6b423df4ae0288c option_static_remotekey + 18. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc @@ -148,7 +166,10 @@ include setup.incl next_commitment_number=2 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey # If tester did not receive node's revoke_and_ack: 1. recv: type=channel_reestablish @@ -156,7 +177,8 @@ include setup.incl next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE # - MUST re-send the `revoke_and_ack` and `commitment_signed` 3. expect-send: type=revoke_and_ack @@ -175,7 +197,8 @@ include setup.incl next_commitment_number=1 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE # - MUST re-send `commitment_signed` 3. expect-send: type=commitment_signed @@ -189,7 +212,8 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE 20. recv: type=revoke_and_ack @@ -229,13 +253,16 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Now it will re-transmit 8. Any order: @@ -250,7 +277,13 @@ include setup.incl 23. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 + # !option_static_remotekey: + # unsigned local commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e903000000000000160014f546ff0865eeecfdef611a3298eca91e656e73b5263d0f00000000002200209d2eb597904551cd8f3b6ee050cef80002b976d5ccf447cefd6a6fc93966580c4eff0020 + signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 !option_static_remotekey + + # option_static_remotekey: + # unsigned local commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e903000000000000160014f0f4189b8cf9f2db0ab8d3a3c009e1823a58842e263d0f00000000002200209d2eb597904551cd8f3b6ee050cef80002b976d5ccf447cefd6a6fc93966580c4eff0020 + signature=a1f6b847503848ae3f3c5b3422fe5a0f953efadacc776163c81927d241c83dac47b9852a5299adf433486f337221816187ca073227c9e82247c980800cc6f3d7 option_static_remotekey htlc_signature= # Optional reconnection testing. @@ -268,7 +301,9 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect - my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect + your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey # tester has not received last commitment_signed 1. recv: type=channel_reestablish @@ -276,7 +311,8 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE # Now it will re-transmit 3. Any order: @@ -290,7 +326,8 @@ include setup.incl payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 + signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 !option_static_remotekey + signature=a1f6b847503848ae3f3c5b3422fe5a0f953efadacc776163c81927d241c83dac47b9852a5299adf433486f337221816187ca073227c9e82247c980800cc6f3d7 option_static_remotekey htlc_signature= # tester *has* received last commitment_signed @@ -299,7 +336,8 @@ include setup.incl next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE 24. recv: type=revoke_and_ack @@ -310,7 +348,8 @@ include setup.incl 25. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=85aebf2874c464db7eac10e0bad98b491c9ac943eae263bb4396d4e5feded12f1284e26196397313be31f4e83334eb5a6641cbec158e0fbfb22c4c488b3a28fd + signature=85aebf2874c464db7eac10e0bad98b491c9ac943eae263bb4396d4e5feded12f1284e26196397313be31f4e83334eb5a6641cbec158e0fbfb22c4c488b3a28fd !option_static_remotekey + signature=b3aebb9a3b29967c6b1b667f0c167e0a6df0ca5b0196f6e8568a7da218e721c459f19525c4ec5cfdb6e2113e717ad6dd689aa38cde81f09d3614de01e72f1221 option_static_remotekey htlc_signature= 26. expect-send: type=revoke_and_ack @@ -334,7 +373,9 @@ include setup.incl next_commitment_number=3 next_revocation_number=2 your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect - my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect + your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect !option_static_remotekey + my_current_per_commitment_point=absent option_static_remotekey # tester *has not* received revoke_and_ack 1. recv: type=channel_reestablish @@ -342,7 +383,8 @@ include setup.incl next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE 3. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -356,5 +398,6 @@ include setup.incl next_commitment_number=3 next_revocation_number=2 your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect - my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect + your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_static_remotekey !option_data_loss_protect + my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE From f99c7abc50bc9de591e0458f6434821241af98e4 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Thu, 10 Oct 2019 11:19:56 -0500 Subject: [PATCH 079/103] featurebits: update feature bit tests now that we support dual_fund and static_remotekey, we needed to update the init tests --- tests/events/bolt1-01-init.events | 34 +++++++++++++++---------------- tools/test-events-clightning.py | 2 ++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/events/bolt1-01-init.events b/tests/events/bolt1-01-init.events index 57b605fe4..938c34d31 100644 --- a/tests/events/bolt1-01-init.events +++ b/tests/events/bolt1-01-init.events @@ -20,23 +20,23 @@ EXPECT_INIT=expect-send: type=init 1. $EXPECT_INIT 2. recv: type=init globalfeatures= localfeatures= - # Sanity check that bits 14 and 15 are not used! - 1. $EXPECT_INIT globalfeatures=0000/C000 - # init msg with unknown odd global bit (15): no error - 2. recv: type=init globalfeatures=8000 localfeatures= + # Sanity check that bits 18 and 19 are not used! + 1. $EXPECT_INIT globalfeatures=000000/030000 + # init msg with unknown odd global bit (19): no error + 2. recv: type=init globalfeatures=020000 localfeatures= - 1. $EXPECT_INIT localfeatures=0000/C000 - # init msg with unknown odd local bit (15): no error - 2. recv: type=init globalfeatures= localfeatures=8000 + 1. $EXPECT_INIT localfeatures=000000/030000 + # init msg with unknown odd local bit (19): no error + 2. recv: type=init globalfeatures= localfeatures=020000 - # init msg with unknown even global bit (14): you will error + # init msg with unknown even global bit (18): you will error 1. $EXPECT_INIT - 2. recv: type=init globalfeatures=4000 localfeatures= + 2. recv: type=init globalfeatures=010000 localfeatures= 3. expect-error: - # init msg with unknown even local bit (14): you will error + # init msg with unknown even local bit (18): you will error 1. $EXPECT_INIT - 2. recv: type=init globalfeatures= localfeatures=4000 + 2. recv: type=init globalfeatures= localfeatures=010000 3. expect-error: # If you don't support `option_data_loss_protect`, you will be ok if @@ -58,20 +58,20 @@ EXPECT_INIT=expect-send: type=init # If you don't support `option_static_remotekey`, you will be ok if # we ask for it. - 1. $EXPECT_INIT localfeatures=0000000000/C000000000 !option_static_remotekey - 2. recv: type=init globalfeatures= localfeatures=02000000000000 !option_static_remotekey + 1. $EXPECT_INIT localfeatures=0000/0C00 !option_static_remotekey + 2. recv: type=init globalfeatures= localfeatures=0800 !option_static_remotekey # If you don't support `option_static_remotekey`, you will error if # we require it. - 1. $EXPECT_INIT localfeatures=0000000000/C000000000 !option_static_remotekey - 2. recv: type=init globalfeatures= localfeatures=01000000000000 !option_static_remotekey + 1. $EXPECT_INIT localfeatures=0000/0C00 !option_static_remotekey + 2. recv: type=init globalfeatures= localfeatures=0400 !option_static_remotekey 3. expect-error: !option_static_remotekey # If you support `option_static_remotekey`, you will advertize it odd. - 1. $EXPECT_INIT localfeatures=02000000000000/03000000000000 option_static_remotekey/odd + 1. $EXPECT_INIT localfeatures=0800/0C00 option_static_remotekey/odd # If you require `option_static_remotekey`, you will advertize it even. - 1. $EXPECT_INIT localfeatures=01000000000000/03000000000000 option_static_remotekey/even + 1. $EXPECT_INIT localfeatures=0400/0C00 option_static_remotekey/even # Note: it's undefined what you'll do if implementation requires # an option and isn't offered it. The recipient of the required feature diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 7e2b8f744..6da1e6149 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -325,6 +325,8 @@ def final_error(self): args.option += ['option_data_loss_protect/odd', 'option_initial_routing_sync/odd', 'option_upfront_shutdown_script/odd', + 'option_static_remotekey/odd', + 'option_dual_fund/odd', 'option_gossip_queries/odd'] # We use a context here, so we can always kill processes at exit From a42c38aea86cff36a514a1470196e65a4a7ad7cb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Nov 2019 16:25:28 +1030 Subject: [PATCH 080/103] test-events.py: Fix printing of unexpected fields. Signed-off-by: Rusty Russell --- tools/test-events.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-events.py b/tools/test-events.py index 6d63e54e8..7400622b0 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -840,7 +840,7 @@ def compare_results(msgname, f, v, exp): # If they specify field=absent, it must not be there. if exp is None: if v is not None: - return "Field {} is present" + return "Field {} is present".format(f.name) else: return None From 4a9720ebca8b9b870f9b371ce5f71081b8bcd536 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Nov 2019 16:26:28 +1030 Subject: [PATCH 081/103] tools/test-events-clightning: autodetect supported features. You can still override on cmdline. Signed-off-by: Rusty Russell --- tools/test-events-clightning.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 6da1e6149..e330ab6a1 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -322,12 +322,9 @@ def final_error(self): parser = test.setup_cmdline_options() args = parser.parse_args() # Here are the options we support. - args.option += ['option_data_loss_protect/odd', - 'option_initial_routing_sync/odd', - 'option_upfront_shutdown_script/odd', - 'option_static_remotekey/odd', - 'option_dual_fund/odd', - 'option_gossip_queries/odd'] + args.option += subprocess.run(['{}/lightningd/lightningd'.format(LIGHTNING_SRC), + '--list-features-only'], + stdout=subprocess.PIPE, check=True).stdout.decode('utf-8').splitlines() # We use a context here, so we can always kill processes at exit with CLightningRunner(args) as runner: From a8117781cc27a3f90d4cc10bde0fae3a4d7a058e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Nov 2019 16:27:28 +1030 Subject: [PATCH 082/103] tools/test-events-clightning: use modern -dev options Signed-off-by: Rusty Russell --- tools/test-events-clightning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index e330ab6a1..b48cc4484 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -138,7 +138,7 @@ def start(self): '--dev-force-bip32-seed=0000000000000000000000000000000000000000000000000000000000000001', '--dev-force-channel-secrets=0000000000000000000000000000000000000000000000000000000000000010/0000000000000000000000000000000000000000000000000000000000000011/0000000000000000000000000000000000000000000000000000000000000012/0000000000000000000000000000000000000000000000000000000000000013/0000000000000000000000000000000000000000000000000000000000000014/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', '--dev-bitcoind-poll=1', - '--dev-broadcast-interval=1000', + '--dev-fast-gossip', '--bind-addr=127.0.0.1:{}'.format(self.lightning_port), '--network=regtest', '--bitcoin-rpcuser=rpcuser', From 0e98ecbeb68efde1630acc167b400126a69ae84e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Nov 2019 16:28:28 +1030 Subject: [PATCH 083/103] tests: fix option_static_remotekey Feature bit is now 13 (0x80000), and we include the my_current_per_commitment_point with option_static_remotekey; we just ignore it. Signed-off-by: Rusty Russell --- tests/events/bolt1-01-init.events | 12 ++--- tests/events/bolt2-02-add-htlc.events | 58 ++++++++++++++--------- tests/events/bolt2-03-htlc-fail.events | 26 ++++++---- tests/events/bolt2-04-htlc-fulfill.events | 22 +++++++-- 4 files changed, 76 insertions(+), 42 deletions(-) diff --git a/tests/events/bolt1-01-init.events b/tests/events/bolt1-01-init.events index 938c34d31..e080ee7f9 100644 --- a/tests/events/bolt1-01-init.events +++ b/tests/events/bolt1-01-init.events @@ -58,20 +58,20 @@ EXPECT_INIT=expect-send: type=init # If you don't support `option_static_remotekey`, you will be ok if # we ask for it. - 1. $EXPECT_INIT localfeatures=0000/0C00 !option_static_remotekey - 2. recv: type=init globalfeatures= localfeatures=0800 !option_static_remotekey + 1. $EXPECT_INIT localfeatures=0000/3000 !option_static_remotekey + 2. recv: type=init globalfeatures= localfeatures=2000 !option_static_remotekey # If you don't support `option_static_remotekey`, you will error if # we require it. - 1. $EXPECT_INIT localfeatures=0000/0C00 !option_static_remotekey - 2. recv: type=init globalfeatures= localfeatures=0400 !option_static_remotekey + 1. $EXPECT_INIT localfeatures=0000/3000 !option_static_remotekey + 2. recv: type=init globalfeatures= localfeatures=1000 !option_static_remotekey 3. expect-error: !option_static_remotekey # If you support `option_static_remotekey`, you will advertize it odd. - 1. $EXPECT_INIT localfeatures=0800/0C00 option_static_remotekey/odd + 1. $EXPECT_INIT localfeatures=2000/3000 option_static_remotekey/odd # If you require `option_static_remotekey`, you will advertize it even. - 1. $EXPECT_INIT localfeatures=0400/0C00 option_static_remotekey/even + 1. $EXPECT_INIT localfeatures=1000/3000 option_static_remotekey/even # Note: it's undefined what you'll do if implementation requires # an option and isn't offered it. The recipient of the required feature diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index c40efd411..9171bd49e 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -18,7 +18,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures=02000000000002 +4. recv: type=init globalfeatures= localfeatures=2002 5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -106,7 +106,7 @@ include setup.incl 3. expect-send: type=init # Note: if we opened channel with option_static_remotekey, it stands even # if we don't negotiate it again! - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 @@ -114,14 +114,16 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey + 7. $MAYBE_UPDATE # BOLT #2: # - if `next_commitment_number` is 1 in both the @@ -156,7 +158,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 @@ -164,13 +166,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=funding_locked @@ -213,7 +216,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -221,13 +224,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # - MUST re-send the `revoke_and_ack`. @@ -245,7 +249,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -253,13 +257,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=commitment_signed @@ -271,7 +276,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -279,13 +284,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE @@ -305,7 +311,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -313,13 +319,14 @@ include setup.incl your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE @@ -343,7 +350,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 @@ -351,13 +358,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=funding_locked @@ -417,7 +425,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -425,13 +433,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # - MUST re-send the `revoke_and_ack`. @@ -449,7 +458,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -457,13 +466,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE 8. expect-send: type=commitment_signed @@ -475,7 +485,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -483,13 +493,14 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE @@ -509,7 +520,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= localfeatures=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -517,12 +528,13 @@ include setup.incl your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events index d9a6fe5a1..28fb1f907 100644 --- a/tests/events/bolt2-03-htlc-fail.events +++ b/tests/events/bolt2-03-htlc-fail.events @@ -18,7 +18,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures=02000000000002 +4. recv: type=init globalfeatures= localfeatures=2002 5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -150,6 +150,8 @@ include setup.incl next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE @@ -208,7 +210,9 @@ include setup.incl next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect - my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey + my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Either way, it should reject HTLC, as it's not a known preimage. @@ -235,13 +239,14 @@ include setup.incl your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Now it will re-transmit @@ -272,13 +277,14 @@ include setup.incl your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Now it will re-transmit @@ -302,13 +308,14 @@ include setup.incl your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE @@ -336,13 +343,14 @@ include setup.incl your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE @@ -376,13 +384,14 @@ include setup.incl your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE @@ -398,12 +407,13 @@ include setup.incl your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 next_revocation_number=2 your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index 689148743..546c81b67 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -22,7 +22,7 @@ include setup.incl 4. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 5. expect-send: type=init -6. recv: type=init globalfeatures= localfeatures=02000000000002 +6. recv: type=init globalfeatures= localfeatures=2002 7. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -169,7 +169,6 @@ include setup.incl your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey # If tester did not receive node's revoke_and_ack: 1. recv: type=channel_reestablish @@ -178,6 +177,8 @@ include setup.incl next_revocation_number=0 your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_data_loss_protect your_last_per_commitment_secret=0000000000000000000000000000000000000000000000000000000000000000 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE # - MUST re-send the `revoke_and_ack` and `commitment_signed` @@ -198,6 +199,8 @@ include setup.incl next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE # - MUST re-send `commitment_signed` @@ -213,6 +216,8 @@ include setup.incl next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE @@ -255,13 +260,14 @@ include setup.incl your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey 6. recv: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 7. $MAYBE_UPDATE # Now it will re-transmit @@ -303,7 +309,6 @@ include setup.incl your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_data_loss_protect your_last_per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey # tester has not received last commitment_signed 1. recv: type=channel_reestablish @@ -312,6 +317,8 @@ include setup.incl next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE # Now it will re-transmit @@ -337,6 +344,8 @@ include setup.incl next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE @@ -375,7 +384,6 @@ include setup.incl your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_data_loss_protect your_last_per_commitment_secret=dddc3a8d14fddf2b68fa8c7fbad2748274937479dd0f8930d5ebb4ab6bd866a3 option_static_remotekey !option_data_loss_protect my_current_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad option_data_loss_protect !option_static_remotekey - my_current_per_commitment_point=absent option_static_remotekey # tester *has not* received revoke_and_ack 1. recv: type=channel_reestablish @@ -384,6 +392,8 @@ include setup.incl next_revocation_number=1 your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_data_loss_protect your_last_per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE 3. expect-send: type=revoke_and_ack @@ -399,5 +409,7 @@ include setup.incl next_revocation_number=2 your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_data_loss_protect your_last_per_commitment_secret=c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964 option_static_remotekey !option_data_loss_protect + # If we have option_static_remotekey, this field is ignored (must be valid point though!) + my_current_per_commitment_point=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 option_static_remotekey my_current_per_commitment_point=02e1ea4f6d28dade887280214c359fc808066a64e750e3c81747dc3074833ff0ad option_data_loss_protect !option_static_remotekey 2. $MAYBE_UPDATE From 5e9c6145b459bef41dda66095e9fd99c91875a9f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Nov 2019 16:28:40 +1030 Subject: [PATCH 084/103] tools/test-events-clightning.py: fix time so gossip tests work. They worked for about two weeks after I wrote them! Signed-off-by: Rusty Russell --- tools/test-events-clightning.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index b48cc4484..8f3ee8553 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -139,6 +139,7 @@ def start(self): '--dev-force-channel-secrets=0000000000000000000000000000000000000000000000000000000000000010/0000000000000000000000000000000000000000000000000000000000000011/0000000000000000000000000000000000000000000000000000000000000012/0000000000000000000000000000000000000000000000000000000000000013/0000000000000000000000000000000000000000000000000000000000000014/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', '--dev-bitcoind-poll=1', '--dev-fast-gossip', + '--dev-gossip-time=1565587763', '--bind-addr=127.0.0.1:{}'.format(self.lightning_port), '--network=regtest', '--bitcoin-rpcuser=rpcuser', From 254ad12e99017dd459746c7410e6eed7d00ff1f3 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Thu, 31 Oct 2019 11:46:29 -0500 Subject: [PATCH 085/103] tests: Add shutdown for executor Will be used later for fundchannel process --- tools/test-events-clightning.py | 2 ++ tools/test-events.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 8f3ee8553..8fecf5dd0 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -165,6 +165,8 @@ def node_ready(rpc): for i in range(5): self.rpc.newaddr() + def shutdown(self): + self.executor.shutdown(wait=False) def stop(self): self.rpc.stop() diff --git a/tools/test-events.py b/tools/test-events.py index 7400622b0..0dc7c73c3 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -182,6 +182,9 @@ def restart(self): print("[RESTART]") self.blockheight = 102 + def shutdown(self): + print("[SHUTDOWN]") + def connect(self, id, line): if self.verbose: print("[CONNECT {}]".format(line)) @@ -1712,6 +1715,8 @@ def main(args, runner): raise if not args.verbose: print('.', end='', flush=True) + + runner.shutdown() print("OK") From b8af7002317069faf46e38d8a2f4c62e03e2f093 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Thu, 31 Oct 2019 11:47:48 -0500 Subject: [PATCH 086/103] tests: add new error type for internal errors --- tools/test-events.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/test-events.py b/tools/test-events.py index 0dc7c73c3..19c527200 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -171,6 +171,12 @@ def __init__(self, line, message): super().__init__(str(line) + ": Parsing failed:" + message) +class InternalError(Exception): + def __init__(self, line, message): + # Call the base class constructor with the parameters it needs + super().__init__(str(line) + ": Error encountered:" + message) + + # #### Dummy runner which you should replace with real one. #### class DummyRunner(object): def __init__(self, args): From 01dbfc6d229626fe8284824d78ffb0b8c520da87 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Thu, 31 Oct 2019 11:51:10 -0500 Subject: [PATCH 087/103] tests: add feerate to fundchannel command Allow for the test to specify the feerate for a fundchannel open --- tools/test-events.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/test-events.py b/tools/test-events.py index 19c527200..87aff5e22 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -221,10 +221,10 @@ def recv(self, conn, outbuf, line): if self.verbose: print("[RECV {} {}]".format(line, outbuf.hex())) - def fundchannel(self, conn, amount, txid, outnum, line): + def fundchannel(self, conn, amount, txid, outnum, feerate, line): if self.verbose: - print("[FUNDCHANNEL TO {} for {} with UTXO {}/{} {}]" - .format(conn, amount, txid, outnum, line)) + print("[FUNDCHANNEL TO {} for {} with UTXO {}/{} {} {}]" + .format(conn, amount, txid, outnum, feerate, line)) def invoice(self, amount, preimage, line): if self.verbose: @@ -1079,17 +1079,18 @@ def action(self, runner, line): class FundChannelEvent(object): def __init__(self, line, parts): - d = parse_params(line, parts, ['amount', 'utxo'], ['conn']) + d = parse_params(line, parts, ['amount', 'utxo', 'feerate'], ['conn']) self.connkey = optional_connection(line, d) self.amount = int(d['amount']) parts = d['utxo'].partition('/') - check_hex(line, parts[0], 66) + check_hex(line, parts[0], 64) self.utxo = (parts[0], int(parts[2])) + self.feerate = d['feerate'] def action(self, runner, line): runner.fundchannel(which_connection(line, runner, self.connkey), self.amount, self.utxo[0], - self.utxo[1], line) + self.utxo[1], self.feerate, line) class InvoiceEvent(object): From 4b476dbd442f927c1d4a29f3de966015712c68cf Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Thu, 31 Oct 2019 11:49:07 -0500 Subject: [PATCH 088/103] test: add fundchannel implementation to c-lightning runner Build out the command for fundchannel, originates open_channel from node under test --- tools/test-events-clightning.py | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 8fecf5dd0..51d19273f 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -254,9 +254,53 @@ def recv(self, conn, outbuf, line): raise test.ValidationError(line, "Connection closed") - # FIXME: Implement fundchannel. - # We'll need to import privkey into bitcoind and hand-generate the tx - # then use fundchannel_start. + def fundchannel(self, conn, amount, txid, outnum, feerate, line): + """ + amount - amount to fund the channel with + txid - txid of the utxo to use + outnum - outnum of the utxo to use + feerate - feerate to use when building the tx + line - line where this event was invoked, for error logging + """ + def _fundchannel(self, amount, txid, outnum, feerate, line): + # node_id, amount, feerate=, announce=, close_to= + if not wait_for(lambda: len(self.rpc.listpeers()['peers']) > 0): + raise test.InternalError(line, "No peers found to fund channel with") + + peer_id = self.rpc.listpeers()['peers'][0]['id'] + result = self.rpc.fundchannel_start(peer_id, amount, feerate=feerate) + + # Build a transaction + funding_addr = result['funding_address'] + tx = self.rpc.txprepare([{funding_addr:amount}], feerate=feerate, utxos=["{}:{}".format(txid, outnum)]) + + # Get the vout index of the funding output + decode = self.bitcoind.rpc.decoderawtransaction(tx['unsigned_tx']) + txout = -1 + for vout in decode['vout']: + if vout['scriptPubKey']['addresses'][0] == funding_addr: + txout = vout['n'] + break + + if txout < 0: + raise test.InternalError(line, + "Unable to find txout for {} (tx:{})".format(funding_addr, decode)) + + self.rpc.fundchannel_complete(peer_id, tx['txid'], txout) + self.rpc.txsend(tx['txid']) + return True + + def _done(fut): + exception = fut.exception(0) + if exception and not self.is_shutdown: + # Exit immediately, instead of waiting for a timeout + self.shutdown() + raise(exception) + + fut = self.executor.submit(_fundchannel, self, amount, + txid, outnum, feerate, line) + fut.add_done_callback(_done) + def invoice(self, amount, preimage, line): self.rpc.invoice(msatoshi=amount, From 3fc25c0b621d71141ce52dd03dad111f776c5121 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Thu, 31 Oct 2019 11:50:05 -0500 Subject: [PATCH 089/103] test: cleaner shutdown of fundchannel on exit If we exit before fundchannel has finished, it shows errors; let's swallow the errors if they're happening on/after shutdown --- tools/test-events-clightning.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 51d19273f..db569c4e2 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -116,6 +116,8 @@ def restart(self): class CLightningRunner(object): def __init__(self, args): self.connections = [] + self.fundchannel_future = None + self.is_shutdown = False directory = tempfile.mkdtemp(prefix='test-events-') self.bitcoind = Bitcoind(directory) self.bitcoind.start() @@ -166,6 +168,13 @@ def node_ready(rpc): self.rpc.newaddr() def shutdown(self): + if self.fundchannel_future: + self.is_shutdown = True + try: + self.fundchannel_future.result(0) + except: + pass + self.fundchannel_future = None self.executor.shutdown(wait=False) def stop(self): @@ -262,6 +271,13 @@ def fundchannel(self, conn, amount, txid, outnum, feerate, line): feerate - feerate to use when building the tx line - line where this event was invoked, for error logging """ + # First, check that another fundchannel isn't already running + if self.fundchannel_future: + if not self.fundchannel_future.done(): + raise test.InternalError(line, + "Called fundchannel while another fundchannel is still in process") + self.fundchannel_future = None + def _fundchannel(self, amount, txid, outnum, feerate, line): # node_id, amount, feerate=, announce=, close_to= if not wait_for(lambda: len(self.rpc.listpeers()['peers']) > 0): @@ -296,10 +312,12 @@ def _done(fut): # Exit immediately, instead of waiting for a timeout self.shutdown() raise(exception) + self.fundchannel_future = None fut = self.executor.submit(_fundchannel, self, amount, txid, outnum, feerate, line) fut.add_done_callback(_done) + self.fundchannel_future = fut def invoice(self, amount, preimage, line): From be5ddaa434bb4b461888cd45bd18bdd13ba03a88 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 1 Nov 2019 16:41:03 -0500 Subject: [PATCH 090/103] tests: kill fundchannel on stop We need to make sure that any fundchannel process is killed by stop, so that we can run multiple fundchannel attempts in the same go Also removes 'shutdown(wait=False)' since it doesn't do anything, really. --- tools/test-events-clightning.py | 34 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index db569c4e2..f8e9f1287 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -114,10 +114,13 @@ def restart(self): class CLightningRunner(object): + def __init__(self, args): self.connections = [] + self.cleanup_callbacks = [] self.fundchannel_future = None - self.is_shutdown = False + self.is_fundchannel_kill = False + directory = tempfile.mkdtemp(prefix='test-events-') self.bitcoind = Bitcoind(directory) self.bitcoind.start() @@ -167,17 +170,23 @@ def node_ready(rpc): for i in range(5): self.rpc.newaddr() - def shutdown(self): - if self.fundchannel_future: - self.is_shutdown = True + def kill_fundchannel(self): + fut = self.fundchannel_future + self.fundchannel_future = None + self.is_fundchannel_kill = True + if fut: try: - self.fundchannel_future.result(0) + fut.result(0) except: pass - self.fundchannel_future = None - self.executor.shutdown(wait=False) + + def shutdown(self): + for cb in self.cleanup_callbacks: + cb() def stop(self): + for cb in self.cleanup_callbacks: + cb() self.rpc.stop() self.bitcoind.stop() for c in self.connections: @@ -191,6 +200,8 @@ def __exit__(self, type, value, tb): self.stop() def restart(self): + for cb in self.cleanup_callbacks: + cb() self.rpc.stop() self.bitcoind.restart() for c in self.connections: @@ -302,22 +313,23 @@ def _fundchannel(self, amount, txid, outnum, feerate, line): raise test.InternalError(line, "Unable to find txout for {} (tx:{})".format(funding_addr, decode)) - self.rpc.fundchannel_complete(peer_id, tx['txid'], txout) + self.rpc.fundchannel_complete(peers[0]['id'], tx['txid'], txout) self.rpc.txsend(tx['txid']) return True def _done(fut): exception = fut.exception(0) - if exception and not self.is_shutdown: - # Exit immediately, instead of waiting for a timeout - self.shutdown() + if exception and not self.is_fundchannel_kill: raise(exception) self.fundchannel_future = None + self.is_fundchannel_kill = False + self.cleanup_callbacks.remove(self.kill_fundchannel) fut = self.executor.submit(_fundchannel, self, amount, txid, outnum, feerate, line) fut.add_done_callback(_done) self.fundchannel_future = fut + self.cleanup_callbacks.append(self.kill_fundchannel) def invoice(self, amount, preimage, line): From a0276fc3bab89d9c9ffc74ce059c2a0dcf820e47 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Mon, 4 Nov 2019 15:30:51 -0600 Subject: [PATCH 091/103] use dev-force-tmp-channel-id, needed for opener tests --- tools/test-events-clightning.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index f8e9f1287..3ce0d6d87 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -139,6 +139,7 @@ def start(self): self.proc = subprocess.Popen(['{}/lightningd/lightningd'.format(LIGHTNING_SRC), '--lightning-dir={}'.format(self.lightning_dir), '--funding-confirms=3', + '--dev-force-tmp-channel-id=0000000000000000000000000000000000000000000000000000000000000000', '--dev-force-privkey=0000000000000000000000000000000000000000000000000000000000000001', '--dev-force-bip32-seed=0000000000000000000000000000000000000000000000000000000000000001', '--dev-force-channel-secrets=0000000000000000000000000000000000000000000000000000000000000010/0000000000000000000000000000000000000000000000000000000000000011/0000000000000000000000000000000000000000000000000000000000000012/0000000000000000000000000000000000000000000000000000000000000013/0000000000000000000000000000000000000000000000000000000000000014/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', From 647da252d215effc03514583da293ef4393905cd Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Tue, 5 Nov 2019 18:19:44 -0600 Subject: [PATCH 092/103] tests: test case for basic opening a channel (opener) Simple 'open channel' check from the opener's perspective. Uses the 'new' fundchannel impl for c-lightning. --- tests/events/bolt2-01-open_channel.events | 2 +- tests/events/bolt2-05-opener_channel.events | 101 ++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 tests/events/bolt2-05-opener_channel.events diff --git a/tests/events/bolt2-01-open_channel.events b/tests/events/bolt2-01-open_channel.events index 40b269baf..6ab87f8b0 100644 --- a/tests/events/bolt2-01-open_channel.events +++ b/tests/events/bolt2-01-open_channel.events @@ -1,4 +1,4 @@ -# Variations on open_channel. +# Variations on open_channel, from the accepter perspective # include setup.incl diff --git a/tests/events/bolt2-05-opener_channel.events b/tests/events/bolt2-05-opener_channel.events new file mode 100644 index 000000000..8850a1ff8 --- /dev/null +++ b/tests/events/bolt2-05-opener_channel.events @@ -0,0 +1,101 @@ +# Variations on open_channel, from the opener perspective +# +include setup.incl + +1. block: $BLOCK_102 + +2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 +3. expect-send: type=init +4. recv: type=init globalfeatures= localfeatures= + +# We set funding_per_kw=253 Satoshi/kSipa. +5. fundchannel: amount=999877 utxo=16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1 feerate=253perkw + + # This gives a channel of 999877sat + 1. expect-send: type=open_channel + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + funding_satoshis=999877 + push_msat=0 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=18446744073709551615 + htlc_minimum_msat=0 + channel_reserve_satoshis=9998 + feerate_per_kw=253 + to_self_delay=6 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 + funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000011 + revocation_basepoint=03defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000012 + payment_basepoint=025601570cb47f238d2b0286db4a990fa0f3ba28d1a319f5e7cf55c2a2444da7cc + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000013 + delayed_payment_basepoint=022b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000014 + htlc_basepoint=024ce119c96e2fa357200b559b2f7dd5a5f02d5290aff74b03f3e471b273211c97 + # shachain seed=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + # first per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + first_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 + channel_flags=01 + + # Ignore unknown odd messages + 1. nothing + 1. recv: type=9999 + + 2. recv: type=accept_channel + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=4294967295 + channel_reserve_satoshis=9998 + htlc_minimum_msat=0 + minimum_depth=3 + # If these are different, the commitment tx will be different! + to_self_delay=6 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 + funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000021 + revocation_basepoint=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000022 + payment_basepoint=031be68a5a028f2601d0e80d468c344ba331d611b96c358b6032e8b4da0547fc11 + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000023 + delayed_payment_basepoint=03605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479 + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000024 + htlc_basepoint=02e0392cfa338aaf2f0b56c563e3e5e67a5d5fefe3388f85d90c899da20f0198f9 + # shachain seed=0000000000000000000000000000000000000000000000000000000000000000 + # first per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 + + # Ignore unknown messages + 1. nothing + 1. recv: type=9999 + + 3. expect-send: type=funding_created + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # Funding tx is + # txid=189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c7560311d + funding_txid=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + funding_output_index=0 + # opener's commitment tx is 02000000011d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c1800000000006d669280010e410f000000000022002002ea9a3a14d15893571391cb43308d0cf2c873025a7ee3e1c59fc94e7d0b820750e05c20 + signature=c30af421f6bba3a2d3a75c90724c14e6332d1f7b77f0d3318fb776a614114f725e56aae2df201ae4d545f063adf412cecc928c073f65e9ad423fdd3abb0bd105 + + 4. recv: type=funding_signed + channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + # accepter's commitment tx is 02000000011d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c1800000000006d669280010e410f000000000016001413619a3971c150996e7d1f391d9ade1405df87ec50e05c20 + signature=758fdb2fd51851d139f0bd815e8383b2c0895b831b3a5bbcaf9aa43d90592e7c79429941fca9f72a1c9b5e6d83b908ed81f0362004c5d53a2cbd74911e7a5735 + + 5. block: height=103 n=3 + + 6. recv: type=funding_locked + channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d + + 7. expect-send: type=funding_locked + channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + + # Ignore unknown odd messages + 1. nothing + 1. recv: type=9999 + From 50de0f70f1e6a66df63e1aa2f86cee84ef53d9d4 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Wed, 13 Nov 2019 14:28:50 -0600 Subject: [PATCH 093/103] tests: add capability to dynamically generate/verify sigs Moving c-lightning over to 'ground' sigs means that it'd be more flexible if the protocol test framework allowed for dynamically generating or verifying sigs based on a hash + private key. Uses ':' notation as a separator so that `htlc_signature` list parsing will still work without modification --- tools/sig-verify.py | 46 ++++++++++++++++++++++++++++++++++++++++++++ tools/test-events.py | 45 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 tools/sig-verify.py diff --git a/tools/sig-verify.py b/tools/sig-verify.py new file mode 100644 index 000000000..904a0b5a4 --- /dev/null +++ b/tools/sig-verify.py @@ -0,0 +1,46 @@ +#! /usr/bin/python3 +# This script verifies hashes from keys, using +# ECDSA over the SECP256k1 curve + +# Released by Lisa Neigut under CC0: +# https://creativecommons.org/publicdomain/zero/1.0/ + +from secp256k1 import PrivateKey + +def verify_sig(secret, hash_digest, sig_bytes): + """ + Verify that the provided signature was in fact + generated by the given private key for the + given hash_digest + + inputs: + - privkey: a hex-string private key scalar + - hash_digest: a hex-string hash message + - sig: a 64-byte array of concatenated r + s values of the signature to verify + + returns: + - True if valid signature, + - False otherwise + """ + if len(sig_bytes) != 64: + raise ValueError("Expected a 64-byte array for sig, got {} ({})".format(len(sig_bytes), sig_bytes.hex())) + + privkey = PrivateKey(bytes(bytearray.fromhex(secret)), raw=True) + sig = privkey.ecdsa_deserialize_compact(sig_bytes) + return privkey.pubkey.ecdsa_verify(bytes(bytearray.fromhex(hash_digest)), sig, raw=True) + + +def generate_sig(secret, hash_digest): + """ + Given a secret (privkey) scalar and hash_digets, + returns a valid signature (64-bytes compact) + + inputs: + privkey: a hex-string private key scalar + hash_digest: a hex-string hash message to sign + + returns: 64-byte compact ecdsa sig + """ + privkey = PrivateKey(bytes(bytearray.fromhex(secret)), raw=True) + sig = privkey.ecdsa_sign(bytes(bytearray.fromhex(hash_digest)), raw=True) + return privkey.ecdsa_serialize_compact(sig) diff --git a/tools/test-events.py b/tools/test-events.py index 87aff5e22..c3e8dcb37 100755 --- a/tools/test-events.py +++ b/tools/test-events.py @@ -6,6 +6,7 @@ import argparse from copy import copy +import importlib import fileinput import networkx as nx from os import path @@ -15,6 +16,9 @@ import sys import matplotlib.pyplot as plt +# Helper for validating / generating signatures +Sigs = importlib.import_module('sig-verify') + # Populated by read_csv messages = [] @@ -129,6 +133,10 @@ def pack(typename, v): if typename in Subtype.objs: return Subtype.objs[typename].pack(v) + # Is 'SIG()' tuple? + if typename == 'signature' and isinstance(v, tuple): + return Sigs.generate_sig(v[0], v[1]) + # Pack directly as bytes assert len(v) == name2size[typename] return bytes(v) @@ -303,6 +311,14 @@ def field_from_str(line, typename, isinteger, s): .format(typename, name2size[typename])) return v + # Special handling for 'SIG(privkey:hash)' + if s.startswith('SIG('): + if not s.endswith(')'): + raise LineError(line, "SIG() improperly formatted. {}".format(s)) + + privkey, hash_digest = s[4:-1].split(':') + return (privkey, hash_digest) + # Everything else is a hex string. try: v = bytes.fromhex(s) @@ -832,8 +848,13 @@ def __init__(self, line, parts): v = values[f.name] if f.arrayvar or f.arraylen: for a in v: + if f.typename == 'signature' and isinstance(a, tuple): + sig = Sigs.generate_sig(a[0], a[1]) + a = sig self.b += pack(f.typename, a) else: + if f.typename == 'signature' and isinstance(v, tuple): + v = Sigs.generate_sig(v[0], v[1]) self.b += pack(f.typename, v) if 'extra' in d: @@ -856,6 +877,27 @@ def compare_results(msgname, f, v, exp): if v is None: return ("Optional field {} is not present" .format(f.name)) + + # Do signature verification, if necessary + if (f.typename == 'signature' and isinstance(exp,tuple)) or (f.typename == 'signature' + and (f.arrayvar or f.arraylen) and isinstance(exp,list)): + if f.arrayvar or f.arraylen: + for (e, val) in list(map(lambda x,y: (x,y), exp, v)): + if isinstance(e, tuple): + if not Sigs.verify_sig(e[0], e[1], val): + return "Invalid signature ({}) for privkey {}, hash {}".format( + val.hex(), e[0], e[1]) + elif e != val: + return ("Expected {}.{}(type:{}) {} but got {}" + .format(msgname, + f.name, f.typename, e.hex(), val.hex())) + else: + # v should be a valid signature, a byte-array r||s + if not Sigs.verify_sig(exp[0], exp[1], v): + return "Invalid signature ({}) for privkey {}, hash {}".format(v.hex(), exp[0], exp[1]) + # Successfully matched all sigs!! + return None + if isinstance(exp, tuple): # Out-of-range bitmaps are considered 0 (eg. feature tests) if len(v) < len(exp[0]): @@ -975,7 +1017,8 @@ def __init__(self, line, parts, maybe=False, mustnot=False): d = parse_params(line, parts, [], optfields) for v in d.keys(): - # IDENTIFIER`=`FIELDVALUE | IDENTIFIER`=`HEX/HEX | `absent` + # IDENTIFIER`=`FIELDVALUE | IDENTIFIER`=`HEX/HEX | `absent` | + # IDENTIFIER`=`SIG(HEX:HEX) f = self.expectmsg.findField(v) parts = d[v].partition('/') From 6a3237c5381c29212a4991ad19867fa4d4be3ed4 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Wed, 13 Nov 2019 14:32:30 -0600 Subject: [PATCH 094/103] tests: update signatures to use SIG() notation missing openchannel, will follow with cleanup --- tests/events/bolt2-02-add-htlc.events | 36 ++++---- tests/events/bolt2-03-htlc-fail.events | 32 +++---- tests/events/bolt2-04-htlc-fulfill.events | 38 ++++---- ...lt7-01-channel_announcement-success.events | 24 +++--- ...t7-02-channel_announcement-failures.events | 86 +++++++++---------- tests/events/setup.incl | 30 +++---- 6 files changed, 123 insertions(+), 123 deletions(-) diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index 9171bd49e..f528396ee 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -73,14 +73,14 @@ include setup.incl funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 funding_output_index=0 # !option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 - signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:97b9f4b67c7d404c82f97d86d7e5b2689e366abf1609abd889143a5999c6df47) !option_static_remotekey # option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74cff0020 - signature=02ce278a17c48e926f93d5134e8f7486e01112a7d06c2ed1b1b5034fb9ace8072d1485ee012440fc85b46cf671a802db4597d482ced68dbfa26ee07b899e936a option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:f116f87d1a90f2d598b37e922dd568a8757a703b197f00fb131d089060f32493) option_static_remotekey 8. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 - signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:49fcc656b58e78f639b8af4bca65fe1ee948ea36eb7629222320518e33a42f29) 9. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 @@ -191,8 +191,8 @@ include setup.incl 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c !option_static_remotekey - signature=05f85dd6f09a5004f11140b2da5b7c1e2debfd84232b04943b26a10da4f30856670e670e6618629f95d3b76f0167a9d906f92f2023884c8b24354b78be8b6fb8 option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:15d8bb3b8ec14a670144d6d06c399e68fe8cf472d889ed65084d86da20064930) !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:a52afdb15b8282c140516e809793bafb5d7d8f20d246ffe390e837c6a03889b8) option_static_remotekey htlc_signature= 3. expect-send: type=revoke_and_ack @@ -203,7 +203,7 @@ include setup.incl 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:8319b604143b4dedec0f3670abdf7d1a1c320aaefe589dba4aefbb1d083ec22d) htlc_signature= # Optional reconnection testing. @@ -242,7 +242,7 @@ include setup.incl next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad 9. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:8319b604143b4dedec0f3670abdf7d1a1c320aaefe589dba4aefbb1d083ec22d) htlc_signature= # If tester did receive node's revoke_and_ack, but not commitment_signed @@ -269,7 +269,7 @@ include setup.incl 7. $MAYBE_UPDATE 8. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:8319b604143b4dedec0f3670abdf7d1a1c320aaefe589dba4aefbb1d083ec22d) htlc_signature= # If tester did receive node's commitment_signed @@ -390,8 +390,8 @@ include setup.incl ## Output 0: LOCAL HTLC 0 # unsigned htlc tx for output 0: 0200000001d3617e206fcf3d62ccaf0328e6ef88b9936afde335552e720226447eb4afffcc000000000000000000013703000000000000220020c950c75b39235322de605f8d8ff7533edf8cfa4e5edd090425c326cfbf4d216700000000 # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 - signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd !option_static_remotekey - htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:e0872852d75887dd5ea2787aa1dee5188b7962ee61750df37475ec01dbd3dd11) !option_static_remotekey + htlc_signature=SIG(54b99d3db5bbf9326bcadd27ff599ec9ec286469482482c1f92f70b31e786177:be34fbaec509cd340a2ced0eaf9cb652ef72f5b4f78e4450cdc592727d7008c6) !option_static_remotekey # option_static_remotekey: ## remote_commitment # input amount 999878sat, funding_wscript 522103d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e652103e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a52ae, key 03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a @@ -399,8 +399,8 @@ include setup.incl # Output 0: LOCAL HTLC 0 # unsigned htlc tx for output 0: 0200000001a366eac6a4f4aad69c3b292d275f1122e34aa97d091ae808422ef4b6d7599c5f000000000000000000013703000000000000220020cdd8da56037931fe7395cbe19893316feb98077ee1acb1b62f31ef850201f29000000000 # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 - signature=69de461fb50707921427c8b204a15188820e21f4711fb72548794ecd036ab8ae1e38461426174f856ec9339f4ad827db42f940f87f916d8e0634521479d1521a option_static_remotekey - htlc_signature=3b04f576ccd0c35ad3fae12434f65a9d04bfe5d185a8ddb3a7afe7fef5a2316842c2e7a201474aaa7272b47db216711986b89adadf93f2fffba7613692c10c7d option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:5a077920e9a7ec1a548de73b44987193d561f0d7b3648e0147b07775fabd2500) option_static_remotekey + htlc_signature=SIG(54b99d3db5bbf9326bcadd27ff599ec9ec286469482482c1f92f70b31e786177:cf81dc68974679ec580ace3aa26e46c06b2bfff16ebf51ccf3c34228b5635339) option_static_remotekey 3. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -412,8 +412,8 @@ include setup.incl channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # Note: because we only have to-self output, signatures don't change # with option_static_remotekey - signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a - htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:6dd008b3a07ec3d19a15eecb5982ef762f43ad04966a279d328062dbb2c1e64b) + htlc_signature=SIG(94549ae2f31fa7adf477a20c34d7c43ec5c4f2144c3ed7281127b00c85f02139:e96e9d7044cb56d55f124a7493f9c13b6389e64ce31efd22e04bb9809a4c3394) # Optional reconnection testing. 1. nothing @@ -451,8 +451,8 @@ include setup.incl next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad 9. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a - htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:6dd008b3a07ec3d19a15eecb5982ef762f43ad04966a279d328062dbb2c1e64b) + htlc_signature=SIG(94549ae2f31fa7adf477a20c34d7c43ec5c4f2144c3ed7281127b00c85f02139:e96e9d7044cb56d55f124a7493f9c13b6389e64ce31efd22e04bb9809a4c3394) # If tester did receive node's revoke_and_ack, but not commitment_signed 1. disconnect: @@ -478,8 +478,8 @@ include setup.incl 7. $MAYBE_UPDATE 8. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a - htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:6dd008b3a07ec3d19a15eecb5982ef762f43ad04966a279d328062dbb2c1e64b) + htlc_signature=SIG(94549ae2f31fa7adf477a20c34d7c43ec5c4f2144c3ed7281127b00c85f02139:e96e9d7044cb56d55f124a7493f9c13b6389e64ce31efd22e04bb9809a4c3394) # If tester did receive node's commitment_signed 1. disconnect: diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events index 28fb1f907..e7c397476 100644 --- a/tests/events/bolt2-03-htlc-fail.events +++ b/tests/events/bolt2-03-htlc-fail.events @@ -73,14 +73,14 @@ include setup.incl funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 funding_output_index=0 # !option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 - signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:97b9f4b67c7d404c82f97d86d7e5b2689e366abf1609abd889143a5999c6df47) !option_static_remotekey # option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74cff0020 - signature=02ce278a17c48e926f93d5134e8f7486e01112a7d06c2ed1b1b5034fb9ace8072d1485ee012440fc85b46cf671a802db4597d482ced68dbfa26ee07b899e936a option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:f116f87d1a90f2d598b37e922dd568a8757a703b197f00fb131d089060f32493) option_static_remotekey 8. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 - signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:49fcc656b58e78f639b8af4bca65fe1ee948ea36eb7629222320518e33a42f29) 9. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 @@ -108,8 +108,8 @@ include setup.incl 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=a42ddd9ab2b171f945e1ac536cd2fc7e4c39d9f0fbb6172f3ec88020e8240033336f9d79ddad09391b41e5127c457abc2d59e59fb398cdd1cd5baed5ba16480c !option_static_remotekey - signature=05f85dd6f09a5004f11140b2da5b7c1e2debfd84232b04943b26a10da4f30856670e670e6618629f95d3b76f0167a9d906f92f2023884c8b24354b78be8b6fb8 option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:15d8bb3b8ec14a670144d6d06c399e68fe8cf472d889ed65084d86da20064930) !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:a52afdb15b8282c140516e809793bafb5d7d8f20d246ffe390e837c6a03889b8) option_static_remotekey htlc_signature= 3. expect-send: type=revoke_and_ack @@ -120,7 +120,7 @@ include setup.incl 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=0c10c223bc7db29d6a9bb054ecf2d72d26e2c73b9ebc653c13a965219f28e29f79e639f01f5082a4b155bbcb0a50acbd5ad9e5c1b4e62b369c57f4b85afa9164 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:8319b604143b4dedec0f3670abdf7d1a1c320aaefe589dba4aefbb1d083ec22d) htlc_signature= 5. recv: type=revoke_and_ack @@ -168,10 +168,10 @@ include setup.incl 2. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=31f6f0ec18b50e61b0c0dc8632d0fc8b7a22883e55c01220d1fd4ad83b752a1a52af1978649e6525334d0c07c739a7537c26d38eaf1d7dab4a7bceffac04f6dd !option_static_remotekey - htlc_signature=fca89064c648f4264bcc6c0f8c630d7fcc9ede23b0eec23658fc772079e7b46f2fbea7265b1057159ba7a44096ef341fc469790997adaeb31dd3b0cf0478dd80 !option_static_remotekey - signature=69de461fb50707921427c8b204a15188820e21f4711fb72548794ecd036ab8ae1e38461426174f856ec9339f4ad827db42f940f87f916d8e0634521479d1521a option_static_remotekey - htlc_signature=3b04f576ccd0c35ad3fae12434f65a9d04bfe5d185a8ddb3a7afe7fef5a2316842c2e7a201474aaa7272b47db216711986b89adadf93f2fffba7613692c10c7d option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:e0872852d75887dd5ea2787aa1dee5188b7962ee61750df37475ec01dbd3dd11) !option_static_remotekey + htlc_signature=SIG(54b99d3db5bbf9326bcadd27ff599ec9ec286469482482c1f92f70b31e786177:be34fbaec509cd340a2ced0eaf9cb652ef72f5b4f78e4450cdc592727d7008c6) !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:5a077920e9a7ec1a548de73b44987193d561f0d7b3648e0147b07775fabd2500) option_static_remotekey + htlc_signature=SIG(54b99d3db5bbf9326bcadd27ff599ec9ec286469482482c1f92f70b31e786177:cf81dc68974679ec580ace3aa26e46c06b2bfff16ebf51ccf3c34228b5635339) option_static_remotekey 3. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -181,8 +181,8 @@ include setup.incl 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=e8653ec993ef47417e941088f1d41bfa5a51bbf1d49d0633389f5a0bf5960918148113a4a7fdd32f114dc945a7db774ed9756ca84bb0e6aa5c330612f294956a - htlc_signature=9c3c9fa3c396aae512aaf7eeed42c3c38b9c8507c6ef60173249118fa823d41f1d93d1fd20c255d242813699332cbd7728c49c72a34653cd84a3fddbe41320c3 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:6dd008b3a07ec3d19a15eecb5982ef762f43ad04966a279d328062dbb2c1e64b) + htlc_signature=SIG(94549ae2f31fa7adf477a20c34d7c43ec5c4f2144c3ed7281127b00c85f02139:e96e9d7044cb56d55f124a7493f9c13b6389e64ce31efd22e04bb9809a4c3394) 5. recv: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -256,7 +256,7 @@ include setup.incl 14. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:34441617fff47a6624d7e0c82d2d5fd6b01013ca1413e65f1d2d46fc5afe5131) htlc_signature= # Optional reconnection testing. @@ -293,7 +293,7 @@ include setup.incl id=0 9. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=2a09e2db7995e4c48feb6ae56bf1a61745250611bfa3cb78865d2cf6c651bc217e1ead697eeafb2bff832ac97f3aae00c24f9e1f57310036381c03b14a5b7a56 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:34441617fff47a6624d7e0c82d2d5fd6b01013ca1413e65f1d2d46fc5afe5131) htlc_signature= # tester *has* received last commitment_signed @@ -356,8 +356,8 @@ include setup.incl 16. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=bd02908f18c3aa740a84b75912a231b9ad773f72ebe2bd0d8d353bef47302e7f08d02272b7077bc8101613695651a756d9339febe714ad5648ff511974c140e7 !option_static_remotekey - signature=f1147918abcc66b802756ed8980bf6432e334e1217a9a7aeb2442e95677e66953beb5c6fe468589481b7e0323b8e5560ea2e675462f8e28bbcad38b50a3ed1e0 option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:f3d47c8ebc473392eae272f60930ef76794476e2738e1a11f5865603f2aa0abb) !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:32c4246f301b7f4d2f8a84628dc729923aec2a2ad2cd60be3836e544294b2b0c) option_static_remotekey htlc_signature= 17. expect-send: type=revoke_and_ack diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index 546c81b67..7d93fa573 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -76,14 +76,14 @@ include setup.incl funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 funding_output_index=0 # !option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 - signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:97b9f4b67c7d404c82f97d86d7e5b2689e366abf1609abd889143a5999c6df47) !option_static_remotekey # option_static_remotekey: node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014e142ca9bfc2d56cd0adb82f8dc870424767389f74cff0020 - signature=02ce278a17c48e926f93d5134e8f7486e01112a7d06c2ed1b1b5034fb9ace8072d1485ee012440fc85b46cf671a802db4597d482ced68dbfa26ee07b899e936a option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:f116f87d1a90f2d598b37e922dd568a8757a703b197f00fb131d089060f32493) option_static_remotekey 10. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 - signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:49fcc656b58e78f639b8af4bca65fe1ee948ea36eb7629222320518e33a42f29) 11. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 @@ -128,8 +128,8 @@ include setup.incl ## Output 0: LOCAL HTLC 1 # unsigned htlc tx for output 0: 02000000014e7c13514515d6baba93a001522446dcb1fbcd73d759b647c9b835cb6c3800c2000000000000000000013703000000000000220020cdd8da56037931fe7395cbe19893316feb98077ee1acb1b62f31ef850201f29000000000 # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a9148139a4b000a75011a6f624005c9482c04160d94588527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 - signature=bc5e1b465773cfe59478c5db35e9f9d27bf832436d0ed0c19833b5e7d444e9f26e3522883a110d71e715471727e3ea7703eba0e6e9855e8d59bc0bf93029bb29 !option_static_remotekey - htlc_signature=8ef6bc3d35a91a00cd1edb0a22e5ca7204b297d41cd7c4cdb1c4167d2d298d907e23b9dc75356ff2fee9ced4abc9fba796a90a2939df45080d12c7bbadbda8d8 !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:d9c6623c3375c009da48e0277d7bf9ef8d0a788405907c815720f7a6c1f974a0) !option_static_remotekey + htlc_signature=SIG(54b99d3db5bbf9326bcadd27ff599ec9ec286469482482c1f92f70b31e786177:ad84fd11115dc61e0542f869c22c24184a03ed3b6cf9ac06cb71e3d9e8c1b3db) !option_static_remotekey # option_static_remotekey: ## remote_commitment # input amount 999878sat, funding_wscript 522103d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e652103e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a52ae, key 03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a @@ -137,8 +137,8 @@ include setup.incl ## Output 0: LOCAL HTLC 1 # unsigned htlc tx for output 0: 020000000162b2ce7a192e54c942c3abca50c0535cb60990f08480c7fbb02cf66d641d6f23000000000000000000013703000000000000220020cdd8da56037931fe7395cbe19893316feb98077ee1acb1b62f31ef850201f29000000000 # wscript: 76a9143eb3762c8c276c6298a7aa4b6891873d3a4cacd88763ac6721037c6136c02af011b4f0f592d2dc7fc8b5b273b394ed8e6457130ad7c74dda0b4f7c8201208763a9148139a4b000a75011a6f624005c9482c04160d94588527c21027f79127629a39c5b967ed0f02a27e50e388efd95fe1601a1b74e50ca0eee92fd52ae677502c800b175ac6868 - signature=aafcc497d0b8e0c7e7593b6447408a058c321a81927153201a981ffa064ba12a761a6d34aedb35450208149f746167bc57026176536c548d7c8b40343bf65a36 option_static_remotekey - htlc_signature=eabc09f68e9195c2097060a5c8e4c1fa692afcf6c52c24ef4db775e299a028fb65445f591fc94f66172b94a2cabb1be4c0b95bd1cf14935cf6b423df4ae0288c option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:c127a333bd94cec1a7b2c443f500c0954c19f605a2f1df58b7ea1bbda4d99532) option_static_remotekey + htlc_signature=SIG(54b99d3db5bbf9326bcadd27ff599ec9ec286469482482c1f92f70b31e786177:40c3525d2e1690d63458ccca18193d59571a695dcdf805206a88e5cda9edff9a) option_static_remotekey 18. expect-send: type=revoke_and_ack channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 @@ -148,8 +148,8 @@ include setup.incl 19. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=64ce07df4f7d4e3e2a29ae6c78baf1d5087a5028f08f537eaed25a5fd1a1f73836d592ff80ba34bbd8f26a0fee17bc8a1fda64006fa4d28f9d52936e17d0abcb - htlc_signature=cfc5c03c510835df5d113b9da9ecdd1b73a602e5bd5a0703c9e53e863da3d8b1193c44913bdc856623f6a706a86256b4939115dec12a79c1f2585cfe7e91a472 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:a52bd92ccb9195c5b45bb2badf390f2c070f20b22edf24fac5cd99f1e1e6db11) + htlc_signature=SIG(94549ae2f31fa7adf477a20c34d7c43ec5c4f2144c3ed7281127b00c85f02139:17b05a9103b123ad6d6c990d6262649c92fa730f00345b9c677608526400b06e) # Optional reconnection testing. 1. nothing @@ -189,8 +189,8 @@ include setup.incl next_per_commitment_point=03bca7c4ebe7eb7e8e40b8c2a7b4dde7f4d48404c9a62859d09fe2d00151af40ad 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=64ce07df4f7d4e3e2a29ae6c78baf1d5087a5028f08f537eaed25a5fd1a1f73836d592ff80ba34bbd8f26a0fee17bc8a1fda64006fa4d28f9d52936e17d0abcb - htlc_signature=cfc5c03c510835df5d113b9da9ecdd1b73a602e5bd5a0703c9e53e863da3d8b1193c44913bdc856623f6a706a86256b4939115dec12a79c1f2585cfe7e91a472 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:a52bd92ccb9195c5b45bb2badf390f2c070f20b22edf24fac5cd99f1e1e6db11) + htlc_signature=SIG(94549ae2f31fa7adf477a20c34d7c43ec5c4f2144c3ed7281127b00c85f02139:17b05a9103b123ad6d6c990d6262649c92fa730f00345b9c677608526400b06e) # If tester did receive node's revoke_and_ack, but not commitment_signed 1. recv: type=channel_reestablish @@ -206,8 +206,8 @@ include setup.incl # - MUST re-send `commitment_signed` 3. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=64ce07df4f7d4e3e2a29ae6c78baf1d5087a5028f08f537eaed25a5fd1a1f73836d592ff80ba34bbd8f26a0fee17bc8a1fda64006fa4d28f9d52936e17d0abcb - htlc_signature=cfc5c03c510835df5d113b9da9ecdd1b73a602e5bd5a0703c9e53e863da3d8b1193c44913bdc856623f6a706a86256b4939115dec12a79c1f2585cfe7e91a472 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:a52bd92ccb9195c5b45bb2badf390f2c070f20b22edf24fac5cd99f1e1e6db11) + htlc_signature=SIG(94549ae2f31fa7adf477a20c34d7c43ec5c4f2144c3ed7281127b00c85f02139:17b05a9103b123ad6d6c990d6262649c92fa730f00345b9c677608526400b06e) # If tester did receive node's commitment_signed 1. recv: type=channel_reestablish @@ -285,11 +285,11 @@ include setup.incl channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # !option_static_remotekey: # unsigned local commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e903000000000000160014f546ff0865eeecfdef611a3298eca91e656e73b5263d0f00000000002200209d2eb597904551cd8f3b6ee050cef80002b976d5ccf447cefd6a6fc93966580c4eff0020 - signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:79d2311d86c38520b3db2477ffc8b971dd518177cbc4c9d8944f819034e45269) !option_static_remotekey # option_static_remotekey: # unsigned local commitment tx: 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a98002e903000000000000160014f0f4189b8cf9f2db0ab8d3a3c009e1823a58842e263d0f00000000002200209d2eb597904551cd8f3b6ee050cef80002b976d5ccf447cefd6a6fc93966580c4eff0020 - signature=a1f6b847503848ae3f3c5b3422fe5a0f953efadacc776163c81927d241c83dac47b9852a5299adf433486f337221816187ca073227c9e82247c980800cc6f3d7 option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:fe72bb88dfa91ff143147b4a1c2a5d42185628b70e77745ac0b35a7592b5e897) option_static_remotekey htlc_signature= # Optional reconnection testing. @@ -333,8 +333,8 @@ include setup.incl payment_preimage=0000000000000000000000000000000000000000000000000000000001000000 4. expect-send: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=282eb3266f88fb48e3614562d9b5ea3d6ff9ffde640d29de194d208f3ea36b955e16a0706df24548f678efc47bab5d59c9baa87d2fcc357b65e4504763dd2956 !option_static_remotekey - signature=a1f6b847503848ae3f3c5b3422fe5a0f953efadacc776163c81927d241c83dac47b9852a5299adf433486f337221816187ca073227c9e82247c980800cc6f3d7 option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:79d2311d86c38520b3db2477ffc8b971dd518177cbc4c9d8944f819034e45269) !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:fe72bb88dfa91ff143147b4a1c2a5d42185628b70e77745ac0b35a7592b5e897) option_static_remotekey htlc_signature= # tester *has* received last commitment_signed @@ -357,8 +357,8 @@ include setup.incl 25. recv: type=commitment_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 - signature=85aebf2874c464db7eac10e0bad98b491c9ac943eae263bb4396d4e5feded12f1284e26196397313be31f4e83334eb5a6641cbec158e0fbfb22c4c488b3a28fd !option_static_remotekey - signature=b3aebb9a3b29967c6b1b667f0c167e0a6df0ca5b0196f6e8568a7da218e721c459f19525c4ec5cfdb6e2113e717ad6dd689aa38cde81f09d3614de01e72f1221 option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:ade3011148ec17fcddb87113a1fb6f1c053b669f81196a1b50f1b3c047d9cfe2) !option_static_remotekey + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:4b9baaa069e2f9d78037e4721609dc8d55249daa36e29f410d74e64cfaf7d645) option_static_remotekey htlc_signature= 26. expect-send: type=revoke_and_ack diff --git a/tests/events/bolt7-01-channel_announcement-success.events b/tests/events/bolt7-01-channel_announcement-success.events index b48e64c8a..2ddaf429c 100644 --- a/tests/events/bolt7-01-channel_announcement-success.events +++ b/tests/events/bolt7-01-channel_announcement-success.events @@ -13,10 +13,10 @@ include setup.incl 5. block: height=103 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c5410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d8187117382024730440220798d96d5a057b5b7797988a855217f41af05ece3ba8278366e2f69763c72e785022065d5dd7eeddc0766ddf65557c92b9c52c301f23f94d2cf681860d32153e6ae1e012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 6. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -33,7 +33,7 @@ include setup.incl 11. disconnect: 12. recv: type=channel_update - signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000002:5133e0542731e0b4b70b4cb99f8fb7dab2e6658b5a5add8d9dfd1a8e2c549f95) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 @@ -49,10 +49,10 @@ include setup.incl 14. expect-send: type=init 15. recv: type=init localfeatures=08 globalfeatures= 16. expect-send: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -61,7 +61,7 @@ include setup.incl bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 17. expect-send: type=channel_update - signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000002:5133e0542731e0b4b70b4cb99f8fb7dab2e6658b5a5add8d9dfd1a8e2c549f95) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 @@ -74,7 +74,7 @@ include setup.incl # And it will relay this, too. 18. recv: conn=0000000000000000000000000000000000000000000000000000000000000003 type=channel_update - signature=0b20265c60b98d6150097ea2ed73a0df4c870ed13defde348c799dd418671ca814837b7b46733d3f28f63b4f36768b44f6ec8dc52fbb08103e27c85ab1188c60 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000003:d86dd6f31dc7956bae1e86407f38548fb2cda5f3f7441577694b1c5d455f153f) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 @@ -86,7 +86,7 @@ include setup.incl fee_proportional_millionths=11 htlc_maximum_msat=100000 19. expect-send: type=channel_update - signature=0b20265c60b98d6150097ea2ed73a0df4c870ed13defde348c799dd418671ca814837b7b46733d3f28f63b4f36768b44f6ec8dc52fbb08103e27c85ab1188c60 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000003:d86dd6f31dc7956bae1e86407f38548fb2cda5f3f7441577694b1c5d455f153f) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 diff --git a/tests/events/bolt7-02-channel_announcement-failures.events b/tests/events/bolt7-02-channel_announcement-failures.events index 0fc8a12fa..0c22f9cd8 100644 --- a/tests/events/bolt7-02-channel_announcement-failures.events +++ b/tests/events/bolt7-02-channel_announcement-failures.events @@ -15,10 +15,10 @@ include setup.incl # It's allowed (even encouraged!) to cache this, so we separate this # from the other tests. 1. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -30,10 +30,10 @@ include setup.incl # Invalid `channel_announcement`: short_channel_id *still* too young. 1. block: height=104 n=4 2. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -47,10 +47,10 @@ include setup.incl # Invalid `channel_announcement`: bad node_signature_1. 1. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f62 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791b) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -62,10 +62,10 @@ include setup.incl # Invalid `channel_announcement`: bad node_signature_2. 1. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98f - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791b) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -77,10 +77,10 @@ include setup.incl # Invalid `channel_announcement`: bad bitcoin_signature_1. 1. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc38 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791b) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -92,10 +92,10 @@ include setup.incl # Invalid `channel_announcement`: bad bitcoin_signature_2. 1. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa13 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791b) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -107,10 +107,10 @@ include setup.incl # Ignored `channel_announcement`: bad chain_hash 1. recv: type=channel_announcement - node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 - node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e - bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 - bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf1889100 short_channel_id=103x1x0 @@ -121,10 +121,10 @@ include setup.incl # Invalid `channel_announcement`: short_channel_id DNE 1. recv: type=channel_announcement - node_signature_1=69d878cc06a2444a92244534aa2a106b2a8270299f20d15a693d2416fa60fb8535342929dfb17fcfcd4f800692d16994861037333a5f9503b3eaf1091acd18b4 - node_signature_2=dc678146f6f55db9d0751e24a045c1ce080aa973c1af9fbec7e2f088bb4eef322b746bb9cfcd3fddbf3b27f0b55517bc3f7e32d25652f51b7f1f7ca86d439b3b - bitcoin_signature_1=d0dca329a8705c92b7aa18f5d42731c31d17a0a0cd104c8e012c9c1f763f4f9857eba89b41264669c64be7316e38cd6c62a23bddb9db25773f28f421220339e4 - bitcoin_signature_2=f8cc9ac5c9147c3077b60f7768403a3f251d421672de0867e6c0314074679d373e9038be8253ae3668586e7cedc50f347725c2296274b7e8e9e26efee9374513 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:31592d21e4e2bb642dd9af658ab9ba629322fc028682f1b2eeb9afd8dfbf5cb5) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:31592d21e4e2bb642dd9af658ab9ba629322fc028682f1b2eeb9afd8dfbf5cb5) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:31592d21e4e2bb642dd9af658ab9ba629322fc028682f1b2eeb9afd8dfbf5cb5) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:31592d21e4e2bb642dd9af658ab9ba629322fc028682f1b2eeb9afd8dfbf5cb5) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x5x0 @@ -135,10 +135,10 @@ include setup.incl # Invalid `channel_announcement`: short_channel_id output DNE 1. recv: type=channel_announcement - node_signature_1=ff3d3d3cf42b2a967b51407d0097fb5bb5035117726ddc16de9758cc1d11d87e65e468e5554b8d69ee2cd3ece701c75417f9a70c7dbd4139732aff0daba31ce4 - node_signature_2=5f709cca17429766bc7057c37d24b3820cc8541ae347b157ca693902b94729d6221000c776011cf427fdf7fff870262cadb4ed91fd44ee1fd7b2e5323d74ba17 - bitcoin_signature_1=0ab5cc881ac52e0e3644831c0a0da7a18c94a2cc51e09b637ba6cff3bedfba8146be0d666a6b82f374bedc682a75491303dd286773b68d97f523df3169cf16b2 - bitcoin_signature_2=9990fd49c489b880bf305fc56946356557c78cb306e915706b4ee02d8eec60497a322018f0e7b1896996860e304a82b3f27ea24038e63c05eb0e8fa1699dabb8 + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:ad0d16d5bcc1826294f8c316e801a95a4f3b1514fed0b9f38e0314ebcc0f2409) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:ad0d16d5bcc1826294f8c316e801a95a4f3b1514fed0b9f38e0314ebcc0f2409) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:ad0d16d5bcc1826294f8c316e801a95a4f3b1514fed0b9f38e0314ebcc0f2409) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:ad0d16d5bcc1826294f8c316e801a95a4f3b1514fed0b9f38e0314ebcc0f2409) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x1 @@ -150,10 +150,10 @@ include setup.incl # Invalid `channel_announcement`: short_channel_id tx does not match # (second bitcoin privkey is ...021 instead of ...020) 1. recv: type=channel_announcement - node_signature_1=97eaa79c72eca400466390454cfaae9805e3e827a396e9f0d91c6abd0371f8136252dad20b56258a4955f78e9e76d063ec9cace9ac0735879fe60620f7502bc9 - node_signature_2=f1c432187bf0cf6629c7c99397f92153960630d2d766a2b59816c34c6a677a121414c20bf9dda865248112248fb0b017020e3676d6ebc6485c4056d55879d829 - bitcoin_signature_1=387ccb63e1dca46f1926de5b963500982eabe9a375d755a804ced67a3977253a2a3bbd525fa0de438b7dc39ec4939a7d81d9c832725005dca77c8fd4ac1dbfa0 - bitcoin_signature_2=0ea3ba77c7644cf34446f1c957cc95f9d2a6aa1abc939e4daddb180e3aa1b01f6c4613cbc9290cdbef74bbdd6a61da58e4ade784edc47795bab4514850f92fce + node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:57b5c0c52e239a20200877037040492feb27a92d0184ac47c979e1ef5c0a0a4a) + node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:57b5c0c52e239a20200877037040492feb27a92d0184ac47c979e1ef5c0a0a4a) + bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:57b5c0c52e239a20200877037040492feb27a92d0184ac47c979e1ef5c0a0a4a) + bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000021:57b5c0c52e239a20200877037040492feb27a92d0184ac47c979e1ef5c0a0a4a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 @@ -166,7 +166,7 @@ include setup.incl # the matching channel_update, which should make it broadcast. 6. connect: privkey=0000000000000000000000000000000000000000000000000000000000000004 7. recv: type=channel_update - signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000002:5133e0542731e0b4b70b4cb99f8fb7dab2e6658b5a5add8d9dfd1a8e2c549f95) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 @@ -177,7 +177,7 @@ include setup.incl fee_base_msat=1000 fee_proportional_millionths=10 8. recv: type=channel_update - signature=b236ed64ff6511baabba2b932e30da95e38c3d533e13870a96bb43150eb86a1453b00da41a5fc1ed5ae20f92c56812b40864996219b1e31188ae40e107e6140d + signature=SIG(0000000000000000000000000000000000000000000000000000000000000002:2ce3390486bfbb1cd2a93022aa6a52e0453f819cc0f233bb7995f4b93bfd787e) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x1 timestamp=1565587763 @@ -188,7 +188,7 @@ include setup.incl fee_base_msat=1000 fee_proportional_millionths=10 9. recv: type=channel_update - signature=0bff9ee3b8e6ef8670b39817c21b9a6cc172ec47f0ea6b4aa4ae2469c3c352267969a0bc70cbdd441fb6f7e305b61cac6d1f16d5e042f8b72742c1d2c9a35e90 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000002:85f489ae81c450943aa159c0013c4536c8a104b5419be6276e61e165956081e6) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x5x0 timestamp=1565587763 diff --git a/tests/events/setup.incl b/tests/events/setup.incl index ba8d2ee94..e3ac04770 100644 --- a/tests/events/setup.incl +++ b/tests/events/setup.incl @@ -41,41 +41,41 @@ BLOCK_102=height=102 tx=020000000001017b8705087f9bddd2777021d2a1dfefc2f1c5afa833 BLOCK_103=height=103 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c5410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d8187117382024730440220798d96d5a057b5b7797988a855217f41af05ece3ba8278366e2f69763c72e785022065d5dd7eeddc0766ddf65557c92b9c52c301f23f94d2cf681860d32153e6ae1e012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 # This channel claimed by nodeids with privkeys ...002 and ...003. -CHAN_ANN_103x1x0=type=channel_announcement node_signature_1=63023be1b5b1f9fbb26fde890032bf4098fba6a78be75a8dd9deae332f6d20ec634806cc3477c41ca565c45089a8331beb3912fb896188b117d525ee17c85f63 node_signature_2=7f2c0664c6205e3c9626b4b7618d18235c059f13579a41dd79ae99e1234d5e8709d295e77c3846b37c44edc7fc4bd1ab07b605c0d216973b6bb4d9dead54b98e bitcoin_signature_1=083ccfe5a766dfe236446ddf52a4f89da5d3f3acc06851f2b0821223a069be02005f5cae7747451b8ae53709723c50fef2c7861c1b8b6bba1043e5bde56dbc39 bitcoin_signature_2=157a587d3495da5b953ba4a9f3a6ad8479a114e4bacbf4262dc257dd86f10db949e6e34e12ef95ead4ba5a9e38b86cd530920b7054914f1ee61ed4261783aa12 features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 +CHAN_ANN_103x1x0=type=channel_announcement node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000010:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000020:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 node_id_1=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 bitcoin_key_1=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a bitcoin_key_2=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 -CHAN_UPDATE_103x1x0_002=type=channel_update signature=76df7e70c63cc2b63ef1c062b99c6d934a80ef2fd4dae9e1d86d277f47674af3255a97fa52ade7f129263f591ed784996eba6383135896cc117a438c80293282 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 message_flags=0 channel_flags=0 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 +CHAN_UPDATE_103x1x0_002=type=channel_update signature=SIG(0000000000000000000000000000000000000000000000000000000000000002:5133e0542731e0b4b70b4cb99f8fb7dab2e6658b5a5add8d9dfd1a8e2c549f95) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 message_flags=0 channel_flags=0 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 -NODE_ANN_002=type=node_announcement signature=f48cc073f61994f978d6fc483cf477bdfd5c754d5deaf055af161fda9039831469432b5d4a08e95242498accf7324dc5918c8efe33dc5c65e17c90121c13320b features= timestamp=1565587763 node_id=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 rgb_color=02c604 alias=3032633630343766393434316564376436643330343534303665393563303763 addresses=01080808082607 +NODE_ANN_002=type=node_announcement signature=SIG(0000000000000000000000000000000000000000000000000000000000000002:511128a78a9a0f1cac973ceb37533497fde5586b54fad3c887d1037195a4ddbd) features= timestamp=1565587763 node_id=02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 rgb_color=02c604 alias=3032633630343766393434316564376436643330343534303665393563303763 addresses=01080808082607 -CHAN_UPDATE_103x1x0_003=type=channel_update signature=0b20265c60b98d6150097ea2ed73a0df4c870ed13defde348c799dd418671ca814837b7b46733d3f28f63b4f36768b44f6ec8dc52fbb08103e27c85ab1188c60 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 message_flags=1 channel_flags=1 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 +CHAN_UPDATE_103x1x0_003=type=channel_update signature=SIG(0000000000000000000000000000000000000000000000000000000000000003:d86dd6f31dc7956bae1e86407f38548fb2cda5f3f7441577694b1c5d455f153f) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=103x1x0 timestamp=1565587763 message_flags=1 channel_flags=1 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 -NODE_ANN_003=type=node_announcement signature=d0b8131bac61b20ecfd04f4ddd7042b98e140bc43ed5ab362ac29516bf0e7fce2c92b1e0f39de68afca2ab8cd1d1205a4847f3116c210b9352fba2d628c9b458 features= timestamp=1565587763 node_id=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 rgb_color=02f930 alias=3032663933303861303139323538633331303439333434663835663839643532 addresses=0151b6887026070220014c4e1cc141001e6f65fffec8a825260703c43068ceb641d7b25c3a26070441cf248da2034dfa9351a9e946d71ce86f561f50b67753fd8e385d44647bf62cdb91032607 +NODE_ANN_003=type=node_announcement signature=SIG(0000000000000000000000000000000000000000000000000000000000000003:15cf94034b8916d507d90d836f8b2a18b6c513b032714056099fb875db9cec3e) features= timestamp=1565587763 node_id=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 rgb_color=02f930 alias=3032663933303861303139323538633331303439333434663835663839643532 addresses=0151b6887026070220014c4e1cc141001e6f65fffec8a825260703c43068ceb641d7b25c3a26070441cf248da2034dfa9351a9e946d71ce86f561f50b67753fd8e385d44647bf62cdb91032607 # A later node-announcement, a little different. -NODE_ANN_003_LATER=type=node_announcement signature=9accff5a0d434eb09b5a3b594af3adc675e223f200a2d488947c6fca39115c885bf87b69963bcac430d0267ef15fe6f7abfa84d4b9be2bb0ee17822d1c02af41 features= timestamp=1565597764 node_id=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 rgb_color=02f930 alias=3032663933303861303139323538633331303439333434663835663839643532 addresses=0441cf248da2034dfa9351a9e946d71ce86f561f50b67753fd8e385d44647bf62cdb91032607 +NODE_ANN_003_LATER=type=node_announcement signature=SIG(0000000000000000000000000000000000000000000000000000000000000003:22de31ba66317a121263102b35cf05fa5c0e5a2100071740428693fa414e9dc5) features= timestamp=1565597764 node_id=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 rgb_color=02f930 alias=3032663933303861303139323538633331303439333434663835663839643532 addresses=0441cf248da2034dfa9351a9e946d71ce86f561f50b67753fd8e385d44647bf62cdb91032607 # Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/0, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000030 and 0000000000000000000000000000000000000000000000000000000000000040 (txid db029ee8cc511625887c192c5bb264249fe69b9b86eb627a52f9a313ba231ade) BLOCK_109=height=109 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160000000000ffffffff0105841e0000000000220020fa73be60259cea454ee79a963514f0b7622db62eadc88daafe377bfa2aa30fbb0247304402205735b9750a90be1ca09cdf91d6697bde3746a390698ca754d516b56c72880bae02203c1deef3645cc20e300db1a808ffc7c2f57be200761ee3cf1a479d1e1aef70bc0121038f1573b4238a986470d250ce87c7a91257b6ba3baf2a0b14380c4e1e532c209d00000000 # This channel claimed by nodeids with privkeys ...004 and ...005. -CHAN_ANN_109x1x0=type=channel_announcement node_signature_1=764be32b3a8839a171a8ad9ef25d326d5c58160029006733ea06978e2806789024a1516575f69c957db8beeb3e5e1452e48db1b3ee085f3d623b47a986539783 node_signature_2=4f71e2785eb9d3833f307f8d954bc7b80f47bdcf483ff41ed9354143dbf62e1b50e31b9f735a26dc1d1ae78e857e0e727761faeaf60c9326cffd232f6ffd74e6 bitcoin_signature_1=8dd1cc39900c5728645b8a031e614b491abb36ff2aa3b529da7bce7091f28d6f237358c168f38a933ed483d9d582af45ee2b078ac9174751a9a4613c3fe4e8e7 bitcoin_signature_2=0bde268ccf1f1e7b245cd23d68e8bda0cb2fe42672bbe693a6a5cf85033fadbe069330dc785665ce8306946d00c16e40035e99db3daf4e1a087ca655f093b14a features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 node_id_1=022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4 node_id_2=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 bitcoin_key_1=03bf23c1542d16eab70b1051eaf832823cfc4c6f1dcdbafd81e37918e6f874ef8b bitcoin_key_2=026eca335d9645307db441656ef4e65b4bfc579b27452bebc19bd870aa1118e5c3 +CHAN_ANN_109x1x0=type=channel_announcement node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000005:dd64b4844ef9728c2486f9bf71273070941f68e4047e8420d764b8e543a2841b) node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000004:dd64b4844ef9728c2486f9bf71273070941f68e4047e8420d764b8e543a2841b) bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000040:dd64b4844ef9728c2486f9bf71273070941f68e4047e8420d764b8e543a2841b) bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000030:dd64b4844ef9728c2486f9bf71273070941f68e4047e8420d764b8e543a2841b) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 node_id_1=022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4 node_id_2=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 bitcoin_key_1=03bf23c1542d16eab70b1051eaf832823cfc4c6f1dcdbafd81e37918e6f874ef8b bitcoin_key_2=026eca335d9645307db441656ef4e65b4bfc579b27452bebc19bd870aa1118e5c3 -CHAN_UPDATE_109x1x0_004=type=channel_update signature=e4328bdcc06a311030d494ee391e000ca8bcdff59f0d071fce10253d43ba65e778c0540c11fb6417a43031da25c5a7b2c38122e92a7111760261967802128219 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 timestamp=1565587764 message_flags=0 channel_flags=1 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 +CHAN_UPDATE_109x1x0_004=type=channel_update signature=SIG(0000000000000000000000000000000000000000000000000000000000000004:d0ba981a8ae3f36494765920e7c2b15c823342baa3a594f5013e699d58d75c7d) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 timestamp=1565587764 message_flags=0 channel_flags=1 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 -NODE_ANN_004=type=node_announcement signature=189a566e9718c5ead7ac99956c0297b56c54bb304c99d3f02235712a376ad09f683cdd8d94d3c71c82fae2a08ea2495cca31426b6d4ec5ac35e83361c15633ef features= timestamp=1565587764 node_id=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 rgb_color=02e493 alias=3032653439336462663163313064383066333538316534393034393330623134 addresses= +NODE_ANN_004=type=node_announcement signature=SIG(0000000000000000000000000000000000000000000000000000000000000004:80307748653b7608ad9932d800581169b4a091de0c5e9084b4d9ff3b96d5d91a) features= timestamp=1565587764 node_id=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 rgb_color=02e493 alias=3032653439336462663163313064383066333538316534393034393330623134 addresses= -NODE_ANN_004_LATER=type=node_announcement signature=3370d9ada9e7b19e81425b32c2f05c5acb650f7ecb45ddb16eec922b1af956c23df932d7b13f6e7e0f230b1565df6ae7e0f7c4251d9a6805e3ef6057dd467cac features= timestamp=1565597765 node_id=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 rgb_color=02e493 alias=3032653439336462663163313064383066333538316534393034393330623134 addresses= +NODE_ANN_004_LATER=type=node_announcement signature=SIG(0000000000000000000000000000000000000000000000000000000000000004:bde4752f90c84e9372c0badf9f0b29a024ed51b623b5f16742f5bb2ca9142f28) features= timestamp=1565597765 node_id=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 rgb_color=02e493 alias=3032653439336462663163313064383066333538316534393034393330623134 addresses= -CHAN_UPDATE_109x1x0_005=type=channel_update signature=06737e9e18d3e4d0ab4066ccaecdcc10e648c5f1c5413f1610747e0d463fa7fa39c1b02ea2fd694275ecfefe4fe9631f24afd182ab75b805e16cd550941f858c chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 timestamp=1565587765 message_flags=1 channel_flags=0 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 +CHAN_UPDATE_109x1x0_005=type=channel_update signature=SIG(0000000000000000000000000000000000000000000000000000000000000005:3f698cd8c502919b5bde2cf02ccd7cb5b3023d73dfd2b8d87da3bcc8fa689963) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=109x1x0 timestamp=1565587765 message_flags=1 channel_flags=0 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 -NODE_ANN_005=type=node_announcement signature=7a553b3933cb5974997c3e294a46ea474a435df2c0d82a0732c0c9700b04e2a6492b2a0620dcfd68e8e64c35b867bc3ec5df4393e3fc3b397095768e2362bae2 features= timestamp=1565587765 node_id=022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4 rgb_color=022f8b alias=3032326638626465346431613037323039333535623461373235306135633531 addresses=022a03b0c0000300d000000000240020012607 +NODE_ANN_005=type=node_announcement signature=SIG(0000000000000000000000000000000000000000000000000000000000000005:cd127af408247cd7e9eac84e1f723e94a43946616be367c9546db1196b108cbe) features= timestamp=1565587765 node_id=022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4 rgb_color=022f8b alias=3032326638626465346431613037323039333535623461373235306135633531 addresses=022a03b0c0000300d000000000240020012607 # Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/3, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000050 and 0000000000000000000000000000000000000000000000000000000000000060 (txid 03330f41079aba9a595310c9c4d78676e5291ee6f1931dd7686f46ed16096186) BLOCK_115=height=115 n=6 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160300000000ffffffff0145c62d00000000002200208225164b456194e9721a5ff5ea4df731d3d663f48f3ba96961dc9d0617ea2bf20247304402200bf2e7a300f8d268c9480732748707b36e43f6225f5330eca2cfa00b21c7159a02205390a3469a14b3a48714bb44db6d8ee838ef5e29b3063a32cba22a3a2d4f3e00012102ffef0c295cf7ca3a4ceb8208534e61edf44c606e7990287f389f1ea055a1231c00000000 # This channel claimed by nodeids with privkeys ...003 and ...004. -CHAN_ANN_115x1x0=type=channel_announcement node_signature_1=91d93a0ac557d03c0cb78b7699ad70ab2e86aed6e1780bd5381637bedbfe202938109484eee1a36a33aa7e0149fa062c502261564e4ecdbebdad5d32657efb82 node_signature_2=dc8cfdb6cdcde9e760f6b21f4d6ce7fe7569143aa253e1ae5339d96b9654422715ca0909f50b612818f9bb9e91fa4729d80d9fe3c16a9af821260a2c1c91888e bitcoin_signature_1=57543ea23aae8231dbe25a89ad1e6d32a4d17f27a84402d7535ec6af3d5c185645d98f605737bc7367660e6084f3d3a2ed2c8a6401feb71057d48f2de5f0961f bitcoin_signature_2=f19424a474fe2d1b573333d0783591a5478616d498f3331d6d0f32f570bce84862731442f0b1d04fa8f94a3bd639e8e7cb1ad5e96795b36f538ab45a90da4a90 features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 node_id_1=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 bitcoin_key_1=033f0e80e574456d8f8fa64e044b2eb72ea22eb53fe1efe3a443933aca7f8cb0e3 bitcoin_key_2=03e9623bbef1bf90ec0d7c744ed34659f010e6e638637161270ecd31e14f87f62e +CHAN_ANN_115x1x0=type=channel_announcement node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000004:4a77eec60b0275f0bdcf1ac572bfd63ff7eaa61050ff54049168e9858279eec0) node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4a77eec60b0275f0bdcf1ac572bfd63ff7eaa61050ff54049168e9858279eec0) bitcoin_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000060:4a77eec60b0275f0bdcf1ac572bfd63ff7eaa61050ff54049168e9858279eec0) bitcoin_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000050:4a77eec60b0275f0bdcf1ac572bfd63ff7eaa61050ff54049168e9858279eec0) features= chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 node_id_1=02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13 node_id_2=02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 bitcoin_key_1=033f0e80e574456d8f8fa64e044b2eb72ea22eb53fe1efe3a443933aca7f8cb0e3 bitcoin_key_2=03e9623bbef1bf90ec0d7c744ed34659f010e6e638637161270ecd31e14f87f62e -CHAN_UPDATE_115x1x0_003=type=channel_update signature=d920087673273a3221e6bf8671e1e3e0b20319c5dd87233c6525a90acaded2c032386032657daccf33e08e9aeb5a590300eb58a3943a89e73814bbf930d72391 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 timestamp=1565597764 message_flags=0 channel_flags=1 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 +CHAN_UPDATE_115x1x0_003=type=channel_update signature=SIG(0000000000000000000000000000000000000000000000000000000000000003:d42e6feecf1cbb4428b026c7a3c76860531518d90ab9ea2aa94eee2fe1daec0a) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 timestamp=1565597764 message_flags=0 channel_flags=1 cltv_expiry_delta=144 htlc_minimum_msat=0 fee_base_msat=1000 fee_proportional_millionths=10 -CHAN_UPDATE_115x1x0_004=type=channel_update signature=ca7bb2adea595eeb448c0139136196557f9f7b52ea0e3d85634bf8d7dd99096440e06e55d2874506ab6dd8d3b9285c0282dae498cb33146314084e37dbf2cff3 chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 timestamp=1565597765 message_flags=1 channel_flags=0 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 +CHAN_UPDATE_115x1x0_004=type=channel_update signature=SIG(0000000000000000000000000000000000000000000000000000000000000004:03d22228832ced80b0f4985ecfea1da3d398cabb213159a66f8eccda312ea58c) chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f short_channel_id=115x1x0 timestamp=1565597765 message_flags=1 channel_flags=0 cltv_expiry_delta=48 htlc_minimum_msat=0 fee_base_msat=100 fee_proportional_millionths=11 htlc_maximum_msat=100000 From cc2919534bed992ee1132a3ba51424a179da80f1 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Wed, 13 Nov 2019 14:33:18 -0600 Subject: [PATCH 095/103] tests: consolidate openchannel tests; use SIG --- tests/events/bolt2-01-open_channel.events | 100 ++++++++++++++++++- tests/events/bolt2-05-opener_channel.events | 101 -------------------- 2 files changed, 97 insertions(+), 104 deletions(-) delete mode 100644 tests/events/bolt2-05-opener_channel.events diff --git a/tests/events/bolt2-01-open_channel.events b/tests/events/bolt2-01-open_channel.events index 6ab87f8b0..8c0b3b855 100644 --- a/tests/events/bolt2-01-open_channel.events +++ b/tests/events/bolt2-01-open_channel.events @@ -1,4 +1,4 @@ -# Variations on open_channel, from the accepter perspective +# Variations on open_channel, accepter + opener perspectives # include setup.incl @@ -8,6 +8,7 @@ include setup.incl 3. expect-send: type=init 4. recv: type=init globalfeatures= localfeatures= + # Start with the 'accepter' side of an open_channel (test runner initiates) # We assume a funding_per_kw=253 Satoshi/kSipa. # This gives a channel of 999878sat 1. recv: type=open_channel @@ -72,12 +73,12 @@ include setup.incl funding_txid=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 funding_output_index=0 # node's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000160014749af8703f0d1fd8890a553bd62e9caf15f7bad44cff0020 - signature=c0c95040f0c132b5773b05fcc59e4a394059db70e6767567f26cbceecc580bcf27da384471a5efdaabd04090dd1d5c3765e849e5fdfe556eabba1ebca806b02a + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:97b9f4b67c7d404c82f97d86d7e5b2689e366abf1609abd889143a5999c6df47) 4. expect-send: type=funding_signed channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 # test's commitment tx is 02000000012f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b08410000000000f436a980010f410f0000000000220020233d69d88092351875ce0b9fd5ea576b2307c539eaed7abdf97fbb26720f01ac4cff0020 - signature=0adfc07a0168630b2e216aa8068dc8aa353be4b622a32ea7629f6d92c37dddcb1f1d605e686d4f49435f415dd9d76174b96b33c7c3e0d5f4eb1d0a9953ad95a1 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:49fcc656b58e78f639b8af4bca65fe1ee948ea36eb7629222320518e33a42f29) 5. block: height=103 n=3 tx=020000000001016b85f654d8186f4d5dd32a977b2cf8c4b01ff4634152acba16b654c1c85a83160100000000ffffffff01c6410f0000000000220020c46bf3d1686d6dbb2d9244f8f67b90370c5aa2747045f1aeccb77d818711738202473044022047e9e6e798ba9adb6c84bdcd6230a96fb6de9dcca84d81103fb2bc08906cb884022027599b1e80289eaf238e9a00119a79a0ccceab7d83d54719e10bd0c3300a0d34012102d6a3c2d0cf7904ab6af54d7c959435a452b24a63194e1c4e7c337d3ebbb3017b00000000 @@ -93,3 +94,96 @@ include setup.incl 1. nothing 1. recv: type=9999 + + # Now we test the 'opener' side of an open_channel (node initiates) + # We set funding_per_kw=253 Satoshi/kSipa. + 1. fundchannel: amount=999877 utxo=16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1 feerate=253perkw + + # This gives a channel of 999877sat + 1. expect-send: type=open_channel + chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + funding_satoshis=999877 + push_msat=0 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=18446744073709551615 + htlc_minimum_msat=0 + channel_reserve_satoshis=9998 + feerate_per_kw=253 + to_self_delay=6 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 + funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000011 + revocation_basepoint=03defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000012 + payment_basepoint=025601570cb47f238d2b0286db4a990fa0f3ba28d1a319f5e7cf55c2a2444da7cc + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000013 + delayed_payment_basepoint=022b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000014 + htlc_basepoint=024ce119c96e2fa357200b559b2f7dd5a5f02d5290aff74b03f3e471b273211c97 + # shachain seed=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + # first per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc + first_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 + channel_flags=01 + + # Ignore unknown odd messages + 1. nothing + 1. recv: type=9999 + + 2. recv: type=accept_channel + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + dust_limit_satoshis=546 + max_htlc_value_in_flight_msat=4294967295 + channel_reserve_satoshis=9998 + htlc_minimum_msat=0 + minimum_depth=3 + # If these are different, the commitment tx will be different! + to_self_delay=6 + max_accepted_htlcs=483 + # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 + funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 + # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000021 + revocation_basepoint=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 + # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000022 + payment_basepoint=031be68a5a028f2601d0e80d468c344ba331d611b96c358b6032e8b4da0547fc11 + # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000023 + delayed_payment_basepoint=03605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479 + # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000024 + htlc_basepoint=02e0392cfa338aaf2f0b56c563e3e5e67a5d5fefe3388f85d90c899da20f0198f9 + # shachain seed=0000000000000000000000000000000000000000000000000000000000000000 + # first per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 + first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 + + # Ignore unknown messages + 1. nothing + 1. recv: type=9999 + + 3. expect-send: type=funding_created + temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 + # Funding tx is + # txid=189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c7560311d + funding_txid=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + funding_output_index=0 + # opener's commitment tx is 02000000011d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c1800000000006d669280010e410f000000000022002002ea9a3a14d15893571391cb43308d0cf2c873025a7ee3e1c59fc94e7d0b820750e05c20 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000010:b5f455ab7e6dc6cbdd0e4f5ff9623091f5e2317d90215734f0b7b468b2de4d9f) + + 4. recv: type=funding_signed + channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + # accepter's commitment tx is 02000000011d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c1800000000006d669280010e410f000000000016001413619a3971c150996e7d1f391d9ade1405df87ec50e05c20 + signature=SIG(0000000000000000000000000000000000000000000000000000000000000020:9afc89f545df32a456355a74f435d9f40bdb0b255f38af3d19ff344ab3ea0ea1) + + 5. block: height=103 n=3 + + 6. recv: type=funding_locked + channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d + + 7. expect-send: type=funding_locked + channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 + next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 + + # Ignore unknown odd messages + 1. nothing + 1. recv: type=9999 + diff --git a/tests/events/bolt2-05-opener_channel.events b/tests/events/bolt2-05-opener_channel.events deleted file mode 100644 index 8850a1ff8..000000000 --- a/tests/events/bolt2-05-opener_channel.events +++ /dev/null @@ -1,101 +0,0 @@ -# Variations on open_channel, from the opener perspective -# -include setup.incl - -1. block: $BLOCK_102 - -2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 -3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures= - -# We set funding_per_kw=253 Satoshi/kSipa. -5. fundchannel: amount=999877 utxo=16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1 feerate=253perkw - - # This gives a channel of 999877sat - 1. expect-send: type=open_channel - chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f - temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 - funding_satoshis=999877 - push_msat=0 - dust_limit_satoshis=546 - max_htlc_value_in_flight_msat=18446744073709551615 - htlc_minimum_msat=0 - channel_reserve_satoshis=9998 - feerate_per_kw=253 - to_self_delay=6 - max_accepted_htlcs=483 - # funding_privkey=0000000000000000000000000000000000000000000000000000000000000010 - funding_pubkey=03e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a - # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000011 - revocation_basepoint=03defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34 - # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000012 - payment_basepoint=025601570cb47f238d2b0286db4a990fa0f3ba28d1a319f5e7cf55c2a2444da7cc - # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000013 - delayed_payment_basepoint=022b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c - # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000014 - htlc_basepoint=024ce119c96e2fa357200b559b2f7dd5a5f02d5290aff74b03f3e471b273211c97 - # shachain seed=ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - # first per_commitment_secret=7cc854b54e3e0dcdb010d7a3fee464a9687be6e8db3be6854c475621e007a5dc - first_per_commitment_point=0288a618cb6027c3218a37cbe9e882379f17d87d03f6e99d0b60292478d2aded06 - channel_flags=01 - - # Ignore unknown odd messages - 1. nothing - 1. recv: type=9999 - - 2. recv: type=accept_channel - temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 - dust_limit_satoshis=546 - max_htlc_value_in_flight_msat=4294967295 - channel_reserve_satoshis=9998 - htlc_minimum_msat=0 - minimum_depth=3 - # If these are different, the commitment tx will be different! - to_self_delay=6 - max_accepted_htlcs=483 - # funding_privkey=0000000000000000000000000000000000000000000000000000000000000020 - funding_pubkey=03d30199d74fb5a22d47b6e054e2f378cedacffcb89904a61d75d0dbd407143e65 - # revocation_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000021 - revocation_basepoint=021697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5 - # payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000022 - payment_basepoint=031be68a5a028f2601d0e80d468c344ba331d611b96c358b6032e8b4da0547fc11 - # delayed_payment_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000023 - delayed_payment_basepoint=03605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479 - # htlc_basepoint_secret=0000000000000000000000000000000000000000000000000000000000000024 - htlc_basepoint=02e0392cfa338aaf2f0b56c563e3e5e67a5d5fefe3388f85d90c899da20f0198f9 - # shachain seed=0000000000000000000000000000000000000000000000000000000000000000 - # first per_commitment_secret=02a40c85b6f28da08dfdbe0926c53fab2de6d28c10301f8f7c4073d5e42e3148 - first_per_commitment_point=02037803a3228ec3a517835480ffac64c0557d9d75e0fe85861ab0be9eb224e6f8 - - # Ignore unknown messages - 1. nothing - 1. recv: type=9999 - - 3. expect-send: type=funding_created - temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 - # Funding tx is - # txid=189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c7560311d - funding_txid=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 - funding_output_index=0 - # opener's commitment tx is 02000000011d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c1800000000006d669280010e410f000000000022002002ea9a3a14d15893571391cb43308d0cf2c873025a7ee3e1c59fc94e7d0b820750e05c20 - signature=c30af421f6bba3a2d3a75c90724c14e6332d1f7b77f0d3318fb776a614114f725e56aae2df201ae4d545f063adf412cecc928c073f65e9ad423fdd3abb0bd105 - - 4. recv: type=funding_signed - channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 - # accepter's commitment tx is 02000000011d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c1800000000006d669280010e410f000000000016001413619a3971c150996e7d1f391d9ade1405df87ec50e05c20 - signature=758fdb2fd51851d139f0bd815e8383b2c0895b831b3a5bbcaf9aa43d90592e7c79429941fca9f72a1c9b5e6d83b908ed81f0362004c5d53a2cbd74911e7a5735 - - 5. block: height=103 n=3 - - 6. recv: type=funding_locked - channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 - next_per_commitment_point=027eed8389cf8eb715d73111b73d94d2c2d04bf96dc43dfd5b0970d80b3617009d - - 7. expect-send: type=funding_locked - channel_id=1d3160756ceeaf5474f389673aafe0484e58260927871ce92f388f72b0409c18 - next_per_commitment_point=032405cbd0f41225d5f203fe4adac8401321a9e05767c5f8af97d51d2e81fbb206 - - # Ignore unknown odd messages - 1. nothing - 1. recv: type=9999 - From e43238d504ce8b2c5f0a6a433347768294c95384 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 2 Dec 2019 16:37:03 +1030 Subject: [PATCH 096/103] tools: update c-lightning runner for modern per-network paths. As changed in commit aab83e729b93d6ce2e2b4702681aaba71462bec8. Signed-off-by: Rusty Russell --- tools/test-events-clightning.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 3ce0d6d87..8a7646f61 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -154,7 +154,7 @@ def start(self): '--log-level=debug', '--log-file=log'] + self.startup_flags) - self.rpc = lightning.LightningRpc(os.path.join(self.lightning_dir, "lightning-rpc")) + self.rpc = lightning.LightningRpc(os.path.join(self.lightning_dir, "regtest", "lightning-rpc")) def node_ready(rpc): try: @@ -209,9 +209,9 @@ def restart(self): c.proc.kill() # Make a clean start - os.remove(os.path.join(self.lightning_dir, "gossip_store")) - os.remove(os.path.join(self.lightning_dir, "lightningd.sqlite3")) - os.remove(os.path.join(self.lightning_dir, "log")) + os.remove(os.path.join(self.lightning_dir, "regtest", "gossip_store")) + os.remove(os.path.join(self.lightning_dir, "regtest", "lightningd.sqlite3")) + os.remove(os.path.join(self.lightning_dir, "regtest", "log")) self.start() def connect(self, conn, line): From 2049a6ed93b7a0396a4a7134991a74dc15eb967d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 2 Dec 2019 16:37:43 +1030 Subject: [PATCH 097/103] tests: update bolt1-01-init "high-numbered" features now 18 and 19 are used. Add another 16 bits. Signed-off-by: Rusty Russell --- tests/events/bolt1-01-init.events | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/events/bolt1-01-init.events b/tests/events/bolt1-01-init.events index e080ee7f9..b8e15cdc7 100644 --- a/tests/events/bolt1-01-init.events +++ b/tests/events/bolt1-01-init.events @@ -20,23 +20,24 @@ EXPECT_INIT=expect-send: type=init 1. $EXPECT_INIT 2. recv: type=init globalfeatures= localfeatures= - # Sanity check that bits 18 and 19 are not used! + # SHOULD NOT set features greater than 13 in `globalfeatures`. 1. $EXPECT_INIT globalfeatures=000000/030000 # init msg with unknown odd global bit (19): no error 2. recv: type=init globalfeatures=020000 localfeatures= - 1. $EXPECT_INIT localfeatures=000000/030000 + # Sanity check that bits 34 and 35 are not used! + 1. $EXPECT_INIT localfeatures=0000000000/0300000000 # init msg with unknown odd local bit (19): no error 2. recv: type=init globalfeatures= localfeatures=020000 - # init msg with unknown even global bit (18): you will error + # init msg with unknown even global bit (34): you will error 1. $EXPECT_INIT - 2. recv: type=init globalfeatures=010000 localfeatures= + 2. recv: type=init globalfeatures=0100000000 localfeatures= 3. expect-error: - # init msg with unknown even local bit (18): you will error + # init msg with unknown even local bit (34): you will error 1. $EXPECT_INIT - 2. recv: type=init globalfeatures= localfeatures=010000 + 2. recv: type=init globalfeatures= localfeatures=0100000000 3. expect-error: # If you don't support `option_data_loss_protect`, you will be ok if From 8d5ef1e5008a93e2d2570f35042d4a62e65f139a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 2 Dec 2019 16:41:25 +1030 Subject: [PATCH 098/103] tools: fix test-events-clightning.py funchannel. NameError: name 'peers' is not defined Signed-off-by: Rusty Russell --- tools/test-events-clightning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-events-clightning.py b/tools/test-events-clightning.py index 8a7646f61..0a802ee1b 100755 --- a/tools/test-events-clightning.py +++ b/tools/test-events-clightning.py @@ -314,7 +314,7 @@ def _fundchannel(self, amount, txid, outnum, feerate, line): raise test.InternalError(line, "Unable to find txout for {} (tx:{})".format(funding_addr, decode)) - self.rpc.fundchannel_complete(peers[0]['id'], tx['txid'], txout) + self.rpc.fundchannel_complete(peer_id, tx['txid'], txout) self.rpc.txsend(tx['txid']) return True From 7a01332becd61dfa37eb2a7dbd2a2f1f345cb11c Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Mon, 2 Dec 2019 13:16:29 -0500 Subject: [PATCH 099/103] tests: Fix broken links in tests/events/README.md --- tests/events/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/events/README.md b/tests/events/README.md index 470ea8679..467424593 100644 --- a/tests/events/README.md +++ b/tests/events/README.md @@ -2,12 +2,12 @@ This directory contains conversation-style tests for Lightning implementations. The format is documented in -[tests/events/test-spec.md](events/test-spec.md), and the base driver for an -implementation is in the [tools/test-events.py](../tools/test-events.py). +[tests/events/test-spec.md](test-spec.md), and the base driver for an +implementation is in the [tools/test-events.py](../../tools/test-events.py). To run the tests, you need to write a driver for your particular implementation, like the one for -[c-lightning](../tools/test-events-clightning.py). Then extract the +[c-lightning](../../tools/test-events-clightning.py). Then extract the format of all messages into a file, like so: $ python3 tools/extract-formats.py 0*.md > format.csv From 58d9b9fc324ab7d7794b0525b320596b65879450 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Tue, 3 Dec 2019 12:47:22 -0500 Subject: [PATCH 100/103] tests: Fix grammatical and consistency errors --- tests/events/test-spec.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index 97f76597c..e6550d1e0 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -1,10 +1,10 @@ -# Format for Event-based Test Specifications. +# Format for Event-based Test Specifications The programmatic test cases for the spec are a tree of events and expected responses which test various scenarios described in the specification. They serve only as guidelines: in some cases a compliant implementation might produce a different response than that -given here, though that suggests further examination of the testcase, +given here, though that suggests further examination of the test case, the implementation, or both. ## General Line Format @@ -32,7 +32,7 @@ a `$` prefix. There's currently no scope to variables. Include lines pull in other files, which is helpful for complex tests. Other lines are indented by multiples of 4 spaces; a line not indented -by a multiple of 4 is be joined to the previous line (this allows +by a multiple of 4 is to be joined with the previous line (this allows nicer formatting for long lines). Each non-comment line indicates something to do to the implementation @@ -46,7 +46,7 @@ STEP1->STEP2a->STEP3 and STEP1->STEP2b->STEP3: 1. STEP2b 2. STEP3 -An step must either have NUMBER 1, in which case it follows directly +A step must either have NUMBER 1, in which case it follows directly from the parent, or NUMBER one greater than the previous step at the same level, in which case it follows the previous. @@ -68,7 +68,7 @@ STEP1->STEP2a->STEP2c->STEP2b, STEP1->STEP2b->STEP2a->STEP2c, STEP1->STEP2b->STEP2c->STEP2a, STEP1->STEP2c->STEP2a->STEP2b, or STEP1->STEP2c->STEP2b->STEP2c. -The special marker `One of:` indicate sequences starting with distinct +The special marker `One of:` indicates sequences starting with distinct output events, only one of which could occur. This is useful for optional outputs which are more constrained, eg: @@ -82,7 +82,7 @@ outputs which are more constrained, eg: This means the test will accept STEP1->STEP2a->STEP2b->STEP3, or STEP1->STEP2c->STEP3. -## Option specifiers +## Option Specifiers OPTION_SPEC := SPACE+ [`!`]OPTION_NAME OPTION_NAME := `opt`IDENTIFIER[`/`ODD_OR_EVEN] @@ -160,7 +160,7 @@ Output events are: * `maybe-send`: a message the implementation may send, at any point from now on (until the next `disconnect`) * `must-not-send`: a message the implementation must not send, at any point from now on (until the next `disconnect`). This implies waiting at the end of the test (for a gossip flush!) to make sure it doesn't send it. * `expect-tx`: a transaction the implementation is expected to broadcast. The transactions here assume deterministic signatures. -* `expect-error`: the implementation is expected to detect an error. This is generally a `expect-send` of `type=error` but it's legal for it to simply close the connection. If there's no `expect-error` event, the implementation is expected *not* to have an error. +* `expect-error`: the implementation is expected to detect an error. This is generally an `expect-send` of `type=error` but it's legal for it to simply close the connection. If there's no `expect-error` event, the implementation is expected *not* to have an error. ## Test Node Setup @@ -199,6 +199,6 @@ The coinbase pays 50 BTC to the following key/address: WIF: cMahea7zqjxrtgAbB7LSGbcQUr1uX1ojuat9jZodMN87JcbXMTcA P2WPKH: bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080 -A further 100 blocks are generated to allow the 50BTC output to be +A further 100 blocks are generated to allow the 50 BTC output to be spent, so block height is 101. The file `setup.incl` contains more helpers for standard setups. From a6c90a81918dcb36f3061611ed25ed621f7e8e1e Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Tue, 3 Dec 2019 12:49:16 -0500 Subject: [PATCH 101/103] tests: Fix `Any order` and `One of` event examples --- tests/events/test-spec.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index e6550d1e0..55fa31afd 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -66,7 +66,7 @@ multiple ways: This means the test will accept STEP1->STEP2a->STEP2b->STEP2c, STEP1->STEP2a->STEP2c->STEP2b, STEP1->STEP2b->STEP2a->STEP2c, STEP1->STEP2b->STEP2c->STEP2a, STEP1->STEP2c->STEP2a->STEP2b, -or STEP1->STEP2c->STEP2b->STEP2c. +or STEP1->STEP2c->STEP2b->STEP2a. The special marker `One of:` indicates sequences starting with distinct output events, only one of which could occur. This is useful for optional @@ -79,8 +79,8 @@ outputs which are more constrained, eg: 1. STEP2c 2. STEP3 -This means the test will accept STEP1->STEP2a->STEP2b->STEP3, or -STEP1->STEP2c->STEP3. +This means the test will accept STEP1->STEP2a->STEP3, STEP1->STEP2b->STEP3, +or STEP1->STEP2c->STEP3. ## Option Specifiers From d73824af8e91270be451a6b06f8672f005e91e3d Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Tue, 3 Dec 2019 13:01:31 -0500 Subject: [PATCH 102/103] tests: Fix INPUT_EVENT specification --- tests/events/test-spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/events/test-spec.md b/tests/events/test-spec.md index 55fa31afd..525e155f0 100644 --- a/tests/events/test-spec.md +++ b/tests/events/test-spec.md @@ -99,7 +99,7 @@ compulsory (`even`). ## Input Events -INPUT_EVENT := CONNECT | RECV | BLOCK | DISCONNECT | OPENCMD +INPUT_EVENT := CONNECT | RECV | BLOCK | DISCONNECT | FUNDCHANCMD | INVOICECMD CONNECT := `connect:` SPACE+ CONNECT_OPTS CONNECT_OPTS := `privkey=` HEX64 From 6ff22bcfcd009950868451c8f7690e9e80f11afc Mon Sep 17 00:00:00 2001 From: darosior Date: Wed, 25 Dec 2019 02:30:31 +0100 Subject: [PATCH 103/103] events: rename 'localfeatures' to 'features' as per 206084c9399abcfacdc95800acc27ebc5ca40b0c --- tests/events/bolt1-01-init.events | 38 +++++++++---------- tests/events/bolt1-02-unknown-messages.events | 2 +- tests/events/bolt2-01-open_channel.events | 2 +- tests/events/bolt2-02-add-htlc.events | 24 ++++++------ tests/events/bolt2-03-htlc-fail.events | 18 ++++----- tests/events/bolt2-04-htlc-fulfill.events | 10 ++--- ...lt7-01-channel_announcement-success.events | 8 ++-- ...t7-02-channel_announcement-failures.events | 4 +- .../bolt7-10-gossip_timestamp_filter.events | 14 +++---- .../bolt7-20-query_channel_range.events | 4 +- .../bolt7-25-query_short_channel_ids.events | 4 +- 11 files changed, 64 insertions(+), 64 deletions(-) diff --git a/tests/events/bolt1-01-init.events b/tests/events/bolt1-01-init.events index b8e15cdc7..f9dc5dd6d 100644 --- a/tests/events/bolt1-01-init.events +++ b/tests/events/bolt1-01-init.events @@ -6,7 +6,7 @@ EXPECT_INIT=expect-send: type=init 1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 2. $EXPECT_INIT -3. recv: type=init globalfeatures= localfeatures= +3. recv: type=init globalfeatures= features= 1. nothing 1. disconnect: @@ -18,61 +18,61 @@ EXPECT_INIT=expect-send: type=init # Minimal possible init message. # Spec: MUST send `init` as the first Lightning message for any connection. 1. $EXPECT_INIT - 2. recv: type=init globalfeatures= localfeatures= + 2. recv: type=init globalfeatures= features= # SHOULD NOT set features greater than 13 in `globalfeatures`. 1. $EXPECT_INIT globalfeatures=000000/030000 # init msg with unknown odd global bit (19): no error - 2. recv: type=init globalfeatures=020000 localfeatures= + 2. recv: type=init globalfeatures=020000 features= # Sanity check that bits 34 and 35 are not used! - 1. $EXPECT_INIT localfeatures=0000000000/0300000000 + 1. $EXPECT_INIT features=0000000000/0300000000 # init msg with unknown odd local bit (19): no error - 2. recv: type=init globalfeatures= localfeatures=020000 + 2. recv: type=init globalfeatures= features=020000 # init msg with unknown even global bit (34): you will error 1. $EXPECT_INIT - 2. recv: type=init globalfeatures=0100000000 localfeatures= + 2. recv: type=init globalfeatures=0100000000 features= 3. expect-error: # init msg with unknown even local bit (34): you will error 1. $EXPECT_INIT - 2. recv: type=init globalfeatures= localfeatures=0100000000 + 2. recv: type=init globalfeatures= features=0100000000 3. expect-error: # If you don't support `option_data_loss_protect`, you will be ok if # we ask for it. - 1. $EXPECT_INIT localfeatures=00/03 !option_data_loss_protect - 2. recv: type=init globalfeatures= localfeatures=02 !option_data_loss_protect + 1. $EXPECT_INIT features=00/03 !option_data_loss_protect + 2. recv: type=init globalfeatures= features=02 !option_data_loss_protect # If you don't support `option_data_loss_protect`, you will error if # we require it. - 1. $EXPECT_INIT localfeatures=00/03 !option_data_loss_protect - 2. recv: type=init globalfeatures= localfeatures=01 !option_data_loss_protect + 1. $EXPECT_INIT features=00/03 !option_data_loss_protect + 2. recv: type=init globalfeatures= features=01 !option_data_loss_protect 3. expect-error: !option_data_loss_protect # If you support `option_data_loss_protect`, you will advertize it odd. - 1. $EXPECT_INIT localfeatures=02/03 option_data_loss_protect/odd + 1. $EXPECT_INIT features=02/03 option_data_loss_protect/odd # If you require `option_data_loss_protect`, you will advertize it even. - 1. $EXPECT_INIT localfeatures=01/03 option_data_loss_protect/even + 1. $EXPECT_INIT features=01/03 option_data_loss_protect/even # If you don't support `option_static_remotekey`, you will be ok if # we ask for it. - 1. $EXPECT_INIT localfeatures=0000/3000 !option_static_remotekey - 2. recv: type=init globalfeatures= localfeatures=2000 !option_static_remotekey + 1. $EXPECT_INIT features=0000/3000 !option_static_remotekey + 2. recv: type=init globalfeatures= features=2000 !option_static_remotekey # If you don't support `option_static_remotekey`, you will error if # we require it. - 1. $EXPECT_INIT localfeatures=0000/3000 !option_static_remotekey - 2. recv: type=init globalfeatures= localfeatures=1000 !option_static_remotekey + 1. $EXPECT_INIT features=0000/3000 !option_static_remotekey + 2. recv: type=init globalfeatures= features=1000 !option_static_remotekey 3. expect-error: !option_static_remotekey # If you support `option_static_remotekey`, you will advertize it odd. - 1. $EXPECT_INIT localfeatures=2000/3000 option_static_remotekey/odd + 1. $EXPECT_INIT features=2000/3000 option_static_remotekey/odd # If you require `option_static_remotekey`, you will advertize it even. - 1. $EXPECT_INIT localfeatures=1000/3000 option_static_remotekey/even + 1. $EXPECT_INIT features=1000/3000 option_static_remotekey/even # Note: it's undefined what you'll do if implementation requires # an option and isn't offered it. The recipient of the required feature diff --git a/tests/events/bolt1-02-unknown-messages.events b/tests/events/bolt1-02-unknown-messages.events index 8881aa36d..50fe30658 100644 --- a/tests/events/bolt1-02-unknown-messages.events +++ b/tests/events/bolt1-02-unknown-messages.events @@ -10,7 +10,7 @@ 1. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 2. expect-send: type=init -3. recv: type=init globalfeatures= localfeatures= +3. recv: type=init globalfeatures= features= 1. nothing diff --git a/tests/events/bolt2-01-open_channel.events b/tests/events/bolt2-01-open_channel.events index 8c0b3b855..4b1b04478 100644 --- a/tests/events/bolt2-01-open_channel.events +++ b/tests/events/bolt2-01-open_channel.events @@ -6,7 +6,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures= +4. recv: type=init globalfeatures= features= # Start with the 'accepter' side of an open_channel (test runner initiates) # We assume a funding_per_kw=253 Satoshi/kSipa. diff --git a/tests/events/bolt2-02-add-htlc.events b/tests/events/bolt2-02-add-htlc.events index f528396ee..2efc8f79c 100644 --- a/tests/events/bolt2-02-add-htlc.events +++ b/tests/events/bolt2-02-add-htlc.events @@ -18,7 +18,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures=2002 +4. recv: type=init globalfeatures= features=2002 5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -106,7 +106,7 @@ include setup.incl 3. expect-send: type=init # Note: if we opened channel with option_static_remotekey, it stands even # if we don't negotiate it again! - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 @@ -158,7 +158,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 @@ -216,7 +216,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -249,7 +249,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -276,7 +276,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -311,7 +311,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -350,7 +350,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=1 @@ -425,7 +425,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -458,7 +458,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -485,7 +485,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -520,7 +520,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=2002 + 4. recv: type=init globalfeatures= features=2002 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 diff --git a/tests/events/bolt2-03-htlc-fail.events b/tests/events/bolt2-03-htlc-fail.events index e7c397476..72c7318db 100644 --- a/tests/events/bolt2-03-htlc-fail.events +++ b/tests/events/bolt2-03-htlc-fail.events @@ -18,7 +18,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init -4. recv: type=init globalfeatures= localfeatures=2002 +4. recv: type=init globalfeatures= features=2002 5. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -136,7 +136,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -197,7 +197,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -231,7 +231,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -269,7 +269,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -300,7 +300,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -335,7 +335,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -376,7 +376,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 @@ -399,7 +399,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 diff --git a/tests/events/bolt2-04-htlc-fulfill.events b/tests/events/bolt2-04-htlc-fulfill.events index 7d93fa573..045185f30 100644 --- a/tests/events/bolt2-04-htlc-fulfill.events +++ b/tests/events/bolt2-04-htlc-fulfill.events @@ -22,7 +22,7 @@ include setup.incl 4. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 5. expect-send: type=init -6. recv: type=init globalfeatures= localfeatures=2002 +6. recv: type=init globalfeatures= features=2002 7. recv: type=open_channel chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f temporary_channel_id=0000000000000000000000000000000000000000000000000000000000000000 @@ -160,7 +160,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -252,7 +252,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -301,7 +301,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=2 @@ -376,7 +376,7 @@ include setup.incl 1. disconnect: 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000002 3. expect-send: type=init - 4. recv: type=init globalfeatures= localfeatures=02 + 4. recv: type=init globalfeatures= features=02 5. expect-send: type=channel_reestablish channel_id=2f0b21d6bd32971ca6803de2bdc7370bbf12e0cd9ce73afc1c591f5c995b0841 next_commitment_number=3 diff --git a/tests/events/bolt7-01-channel_announcement-success.events b/tests/events/bolt7-01-channel_announcement-success.events index 2ddaf429c..197e0f50c 100644 --- a/tests/events/bolt7-01-channel_announcement-success.events +++ b/tests/events/bolt7-01-channel_announcement-success.events @@ -6,7 +6,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 3. expect-send: type=init -4. recv: type=init localfeatures= globalfeatures= +4. recv: type=init features= globalfeatures= # Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000010 and 0000000000000000000000000000000000000000000000000000000000000020 # txid 189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c7560311d @@ -28,7 +28,7 @@ include setup.incl # New peer connects, asking for initial_routing_sync. We *won't* relay channel_announcement, as there is no channel_update. 7. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 8. expect-send: type=init -9. recv: type=init localfeatures=08 globalfeatures= +9. recv: type=init features=08 globalfeatures= 10. must-not-send: type=channel_announcement 11. disconnect: @@ -47,7 +47,7 @@ include setup.incl # Now we'll relay to a new peer. 13. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 14. expect-send: type=init -15. recv: type=init localfeatures=08 globalfeatures= +15. recv: type=init features=08 globalfeatures= 16. expect-send: type=channel_announcement node_signature_1=SIG(0000000000000000000000000000000000000000000000000000000000000002:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) node_signature_2=SIG(0000000000000000000000000000000000000000000000000000000000000003:4ad0946fa8c3996015dec325c4b0540299287427ec8d8313842ce6f8dc06791a) @@ -105,6 +105,6 @@ include setup.incl 22. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 23. expect-send: type=init -24. recv: type=init localfeatures=08 globalfeatures= +24. recv: type=init features=08 globalfeatures= 25. must-not-send: type=channel_announcement 26. must-not-send: type=channel_update diff --git a/tests/events/bolt7-02-channel_announcement-failures.events b/tests/events/bolt7-02-channel_announcement-failures.events index 0c22f9cd8..3f581376f 100644 --- a/tests/events/bolt7-02-channel_announcement-failures.events +++ b/tests/events/bolt7-02-channel_announcement-failures.events @@ -5,7 +5,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 3. expect-send: type=init -4. recv: type=init localfeatures= globalfeatures= +4. recv: type=init features= globalfeatures= # Funding tx spending 16835ac8c154b616baac524163f41fb0c4f82c7b972ad35d4d6f18d854f6856b/1, feerate 253 to bitcoin privkeys 0000000000000000000000000000000000000000000000000000000000000010 and 0000000000000000000000000000000000000000000000000000000000000020 # txid 189c40b0728f382fe91c87270926584e48e0af3a6789f37454afee6c7560311d @@ -202,6 +202,6 @@ include setup.incl # New peer connects, asking for initial_routing_sync. We *won't* relay channel_announcement. 10. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 11. expect-send: type=init -12. recv: type=init localfeatures=08 globalfeatures= +12. recv: type=init features=08 globalfeatures= 13. must-not-send: type=channel_announcement 14. must-not-send: type=channel_update diff --git a/tests/events/bolt7-10-gossip_timestamp_filter.events b/tests/events/bolt7-10-gossip_timestamp_filter.events index bb25211cd..5b3186cee 100644 --- a/tests/events/bolt7-10-gossip_timestamp_filter.events +++ b/tests/events/bolt7-10-gossip_timestamp_filter.events @@ -6,7 +6,7 @@ include setup.incl 2. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 3. expect-send: type=init -4. recv: type=init localfeatures= globalfeatures= +4. recv: type=init features= globalfeatures= 5. block: $BLOCK_103 @@ -16,7 +16,7 @@ include setup.incl # New peer connects, asks for gossip_timestamp_filter=all. We *won't* relay channel_announcement, as there is no channel_update. 8. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 9. expect-send: type=init -10. recv: type=init localfeatures= globalfeatures= +10. recv: type=init features= globalfeatures= 11. recv: type=gossip_timestamp_filter chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_timestamp=0 @@ -30,7 +30,7 @@ include setup.incl # New peer connects, asks for gossip_timestamp_filter=all. update and node announcement will be relayed. 16. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 17. expect-send: type=init -18. recv: type=init localfeatures= globalfeatures= +18. recv: type=init features= globalfeatures= 19. recv: type=gossip_timestamp_filter chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_timestamp=0 @@ -49,7 +49,7 @@ include setup.incl 23. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 24. expect-send: type=init -25. recv: type=init localfeatures= globalfeatures= +25. recv: type=init features= globalfeatures= 26. recv: type=gossip_timestamp_filter chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_timestamp=1000 @@ -61,7 +61,7 @@ include setup.incl 31. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 32. expect-send: type=init -33. recv: type=init localfeatures= globalfeatures= +33. recv: type=init features= globalfeatures= 34. recv: type=gossip_timestamp_filter chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_timestamp=1565587764 @@ -74,7 +74,7 @@ include setup.incl # These two succeed in getting the gossip, then stay connected for next test. 39. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 40. expect-send: type=init -41. recv: type=init localfeatures= globalfeatures= +41. recv: type=init features= globalfeatures= 42. recv: type=gossip_timestamp_filter chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_timestamp=1565587763 @@ -86,7 +86,7 @@ include setup.incl 45. connect: privkey=0000000000000000000000000000000000000000000000000000000000000006 46. expect-send: type=init -47. recv: type=init localfeatures= globalfeatures= +47. recv: type=init features= globalfeatures= 48. recv: type=gossip_timestamp_filter chain_hash=06226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f first_timestamp=1000 diff --git a/tests/events/bolt7-20-query_channel_range.events b/tests/events/bolt7-20-query_channel_range.events index bb876d5e5..2cafa2d4b 100644 --- a/tests/events/bolt7-20-query_channel_range.events +++ b/tests/events/bolt7-20-query_channel_range.events @@ -15,7 +15,7 @@ include setup.incl 4. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 5. expect-send: type=init -6. recv: type=init localfeatures= globalfeatures= +6. recv: type=init features= globalfeatures= # They can send this, we'll ignore it. 7. maybe-send: type=gossip_timestamp_filter @@ -31,7 +31,7 @@ include setup.incl # New peer connects, with gossip_query option. 13. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 14. expect-send: type=init -15. recv: type=init localfeatures=80 globalfeatures= +15. recv: type=init features=80 globalfeatures= 16. maybe-send: type=gossip_timestamp_filter # No queries? Must not get anything. diff --git a/tests/events/bolt7-25-query_short_channel_ids.events b/tests/events/bolt7-25-query_short_channel_ids.events index 8efdbdf61..aa8c34669 100644 --- a/tests/events/bolt7-25-query_short_channel_ids.events +++ b/tests/events/bolt7-25-query_short_channel_ids.events @@ -10,7 +10,7 @@ include setup.incl 5. connect: privkey=0000000000000000000000000000000000000000000000000000000000000003 6. expect-send: type=init -7. recv: type=init localfeatures= globalfeatures= +7. recv: type=init features= globalfeatures= # They can send this, we'll ignore it. 8. maybe-send: type=gossip_timestamp_filter @@ -33,7 +33,7 @@ include setup.incl # New peer connects, with gossip_query option. 18. connect: privkey=0000000000000000000000000000000000000000000000000000000000000005 19. expect-send: type=init -20. recv: type=init localfeatures=80 globalfeatures= +20. recv: type=init features=80 globalfeatures= 21. maybe-send: type=gossip_timestamp_filter # Query for non-existent channels (104x1x0 105x1x0 106x1x0 107x1x0)