Browse Source

Make option_static_remotekey non-EXPERIMENTAL now it's in spec.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
15612d269a
  1. 1
      CHANGELOG.md
  2. 2
      Makefile
  3. 18
      channeld/channeld.c
  4. 2
      common/features.c
  5. 2
      common/features.h
  6. 7
      common/key_derive.c
  7. 4
      common/keyset.c
  8. 2
      hsmd/hsmd.c
  9. 3
      lightningd/channel_control.c
  10. 3
      lightningd/closing_control.c
  11. 2
      lightningd/opening_control.c
  12. 2
      onchaind/onchaind.c
  13. 8
      tests/test_connection.py
  14. 7
      tests/test_misc.py
  15. 12
      wire/extracted_peer_experimental_legacy
  16. 4
      wire/extracted_peer_wire_csv

1
CHANGELOG.md

@ -261,6 +261,7 @@ This release named by @molxyz and [@ctrlbreak](https://twitter.com/ctrlbreak).
- JSON API: `listpeers`'s `channels` now includes a `private` flag to indicate if channel is announced or not.
- JSON API: `invoice` route hints may now include private channels if you have no public ones, unless new option `exposeprivatechannels` is false.
- Plugins: experimental plugin support for `lightningd`, including option passthrough and JSON-RPC passthrough.
- Protocol: we now support features `option_static_remotekey` and `gossip_queries_ex` for peers.
### Changed

2
Makefile

@ -15,7 +15,7 @@ CCANDIR := ccan
# Where we keep the BOLT RFCs
BOLTDIR := ../lightning-rfc/
BOLTVERSION := c8e53fe5bf131db142d231e88f2adb3a84876836
BOLTVERSION := 2afe3559e89520ba28b24ff5739491313217ae13
-include config.vars

18
channeld/channeld.c

@ -2014,7 +2014,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last
peer->revocations_received);
}
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2:
/* BOLT #2:
*
* A receiving node:
* - if `option_static_remotekey` applies to the commitment transaction:
@ -2077,7 +2077,7 @@ static void check_future_dataloss_fields(struct peer *peer,
peer_failed(peer->pps, &peer->channel_id, "Awaiting unilateral close");
}
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2:
/* BOLT #2:
*
* A receiving node:
* - if `option_static_remotekey` applies to the commitment transaction:
@ -2239,7 +2239,7 @@ static void peer_reconnect(struct peer *peer,
get_per_commitment_point(peer->next_index[LOCAL] - 1,
&my_current_per_commitment_point, NULL);
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2:
/* BOLT #2:
*
* - upon reconnection:
* - if a channel is in an error state:
@ -2272,7 +2272,6 @@ static void peer_reconnect(struct peer *peer,
* - MUST set `your_last_per_commitment_secret` to the last
* `per_commitment_secret` it received
*/
#if EXPERIMENTAL_FEATURES
if (peer->channel->option_static_remotekey) {
msg = towire_channel_reestablish_option_static_remotekey
(NULL, &peer->channel_id,
@ -2281,9 +2280,7 @@ static void peer_reconnect(struct peer *peer,
last_remote_per_commit_secret,
/* Can send any (valid) point here */
&peer->remote_per_commit);
} else
#endif /* EXPERIMENTAL_FEATURES */
if (dataloss_protect) {
} else if (dataloss_protect) {
msg = towire_channel_reestablish_option_data_loss_protect
(NULL, &peer->channel_id,
peer->next_index[LOCAL],
@ -2310,7 +2307,6 @@ static void peer_reconnect(struct peer *peer,
} while (handle_peer_gossip_or_error(peer->pps, &peer->channel_id, msg)
|| capture_premature_msg(&premature_msgs, msg));
#if EXPERIMENTAL_FEATURES
if (peer->channel->option_static_remotekey) {
struct pubkey ignore;
if (!fromwire_channel_reestablish_option_static_remotekey(msg,
@ -2325,9 +2321,7 @@ static void peer_reconnect(struct peer *peer,
wire_type_name(fromwire_peektype(msg)),
tal_hex(msg, msg));
}
} else
#endif /* EXPERIMENTAL_FEATURES */
if (dataloss_protect) {
} else if (dataloss_protect) {
if (!fromwire_channel_reestablish_option_data_loss_protect(msg,
&channel_id,
&next_commitment_number,
@ -3023,9 +3017,7 @@ static void init_channel(struct peer *peer)
feerate_per_kw[LOCAL], feerate_per_kw[REMOTE],
peer->feerate_min, peer->feerate_max);
#if EXPERIMENTAL_FEATURES
status_debug("option_static_remotekey = %u", option_static_remotekey);
#endif
if(remote_ann_node_sig && remote_ann_bitcoin_sig) {
peer->announcement_node_sigs[REMOTE] = *remote_ann_node_sig;

2
common/features.c

@ -9,9 +9,7 @@ static const u32 our_localfeatures[] = {
OPTIONAL_FEATURE(LOCAL_UPFRONT_SHUTDOWN_SCRIPT),
OPTIONAL_FEATURE(LOCAL_GOSSIP_QUERIES),
OPTIONAL_FEATURE(LOCAL_GOSSIP_QUERIES_EX),
#if EXPERIMENTAL_FEATURES
OPTIONAL_FEATURE(LOCAL_STATIC_REMOTEKEY),
#endif
};
static const u32 our_globalfeatures[] = {

2
common/features.h

@ -53,7 +53,7 @@ void set_feature_bit(u8 **ptr, u32 bit);
#define LOCAL_GOSSIP_QUERIES 6
#define LOCAL_GOSSIP_QUERIES_EX 10
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #9:
/* BOLT #9:
* | Bits | Name |...
* | 12/13| `option_static_remotekey` |...
*/

7
common/key_derive.c

@ -7,18 +7,21 @@
/* BOLT #3:
*
* ### `localpubkey`, `remotepubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation
* ### `localpubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation
*
* These pubkeys are simply generated by addition from their base points:
*
* pubkey = basepoint + SHA256(per_commitment_point || basepoint) * G
*
* The `localpubkey` uses the local node's `payment_basepoint`;
* the `remotepubkey` uses the remote node's `payment_basepoint`;
* the `local_htlcpubkey` uses the local node's `htlc_basepoint`;
* the `remote_htlcpubkey` uses the remote node's `htlc_basepoint`;
* the `local_delayedpubkey` uses the local node's `delayed_payment_basepoint`;
* and the `remote_delayedpubkey` uses the remote node's `delayed_payment_basepoint`.
*...
* If `option_static_remotekey` is negotiated the `remotepubkey` is simply the
* remote node's `payment_basepoint`, otherwise it is calculated as above using
* the remote node's `payment_basepoint`.
*/
bool derive_simple_key(const struct pubkey *basepoint,
const struct pubkey *per_commitment_point,

4
common/keyset.c

@ -8,7 +8,7 @@ bool derive_keyset(const struct pubkey *per_commitment_point,
bool option_static_remotekey,
struct keyset *keyset)
{
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3:
/* BOLT #3:
*
* ### `localpubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation
*
@ -27,7 +27,7 @@ bool derive_keyset(const struct pubkey *per_commitment_point,
&keyset->self_payment_key))
return false;
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3:
/* BOLT #3:
*
* ### `remotepubkey` Derivation
*

2
hsmd/hsmd.c

@ -1385,7 +1385,7 @@ static void hsm_unilateral_close_privkey(struct privkey *dst,
get_channel_seed(&info->peer_id, info->channel_id, &channel_seed);
derive_basepoints(&channel_seed, NULL, &basepoints, &secrets, NULL);
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3:
/* BOLT #3:
*
* If `option_static_remotekey` is negotiated the `remotepubkey`
* is simply the remote node's `payment_basepoint`, otherwise it is

3
lightningd/channel_control.c

@ -391,9 +391,6 @@ void peer_start_channeld(struct channel *channel,
num_revocations = revocations_received(&channel->their_shachain.chain);
/* BOLT #2:
*
* - if it supports `option_data_loss_protect`:
*...
* - if `next_revocation_number` equals 0:
* - MUST set `your_last_per_commitment_secret` to all zeroes
* - otherwise:

3
lightningd/closing_control.c

@ -245,9 +245,6 @@ void peer_start_closingd(struct channel *channel,
}
/* BOLT #2:
*
* - if it supports `option_data_loss_protect`:
*...
* - if `next_revocation_number` equals 0:
* - MUST set `your_last_per_commitment_secret` to all zeroes
* - otherwise:

2
lightningd/opening_control.c

@ -198,7 +198,7 @@ wallet_commit_channel(struct lightningd *ld,
/* old_remote_per_commit not valid yet, copy valid one. */
channel_info->old_remote_per_commit = channel_info->remote_per_commit;
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #2:
/* BOLT #2:
* 1. type: 35 (`funding_signed`)
* 2. data:
* * [`channel_id`:`channel_id`]

2
onchaind/onchaind.c

@ -2485,7 +2485,7 @@ static void handle_unknown_commitment(const struct bitcoin_tx *tx,
local_script = scriptpubkey_p2wpkh(tmpctx,
&ks->other_payment_key);
} else {
/* BOLT-531c8d7d9b01ab610b8a73a0deba1b9e9c83e1ed #3:
/* BOLT #3:
*
* ### `remotepubkey` Derivation
*

8
tests/test_connection.py

@ -3,7 +3,7 @@ from decimal import Decimal
from fixtures import * # noqa: F401,F403
from flaky import flaky # noqa: F401
from lightning import RpcError
from utils import DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT, SLOW_MACHINE, EXPERIMENTAL_FEATURES
from utils import DEVELOPER, only_one, wait_for, sync_blockheight, VALGRIND, TIMEOUT, SLOW_MACHINE
from bitcoin.core import CMutableTransaction, CMutableTxOut
import binascii
@ -1382,8 +1382,6 @@ def test_forget_channel(node_factory):
def test_peerinfo(node_factory, bitcoind):
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'may_reconnect': True})
lfeatures = '08a2'
if EXPERIMENTAL_FEATURES:
lfeatures = '28a2'
# Gossiping but no node announcement yet
assert l1.rpc.getpeer(l2.info['id'])['connected']
@ -1636,12 +1634,8 @@ def test_dataloss_protection(node_factory, bitcoind):
l2 = node_factory.get_node(may_reconnect=True, log_all_io=True,
feerates=(7500, 7500, 7500), allow_broken_log=True)
if EXPERIMENTAL_FEATURES:
# features 1, 3, 7, 11 and 13 (0x28a2).
lf = "28a2"
else:
# features 1, 3, 7 and 11 (0x08a2).
lf = "08a2"
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
# l1 should send out WIRE_INIT (0010)
l1.daemon.wait_for_log(r"\[OUT\] 0010"

7
tests/test_misc.py

@ -3,7 +3,7 @@ from fixtures import * # noqa: F401,F403
from flaky import flaky # noqa: F401
from lightning import RpcError
from threading import Event
from utils import DEVELOPER, TIMEOUT, VALGRIND, sync_blockheight, only_one, wait_for, TailableProc, EXPERIMENTAL_FEATURES
from utils import DEVELOPER, TIMEOUT, VALGRIND, sync_blockheight, only_one, wait_for, TailableProc
from ephemeral_port_reserve import reserve
import json
@ -1446,7 +1446,6 @@ def test_list_features_only(node_factory):
expected = ['option_data_loss_protect/odd',
'option_upfront_shutdown_script/odd',
'option_gossip_queries/odd',
'option_gossip_queries_ex/odd']
if EXPERIMENTAL_FEATURES:
expected += ['option_static_remotekey/odd']
'option_gossip_queries_ex/odd',
'option_static_remotekey/odd']
assert features == expected

12
wire/extracted_peer_experimental_legacy

@ -1,12 +0,0 @@
--- wire/extracted_peer_wire_csv 2019-08-01 11:33:48.136457293 +0930
+++ - 2019-08-01 11:40:21.313665504 +0930
@@ -108,7 +108,7 @@
msgdata,channel_reestablish,channel_id,channel_id,
msgdata,channel_reestablish,next_commitment_number,u64,
msgdata,channel_reestablish,next_revocation_number,u64,
-msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect
+msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect,option_static_remotekey
-msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect
+msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect,option_static_remotekey
msgtype,announcement_signatures,259
msgdata,announcement_signatures,channel_id,channel_id,

4
wire/extracted_peer_wire_csv

@ -122,8 +122,8 @@ msgtype,channel_reestablish,136
msgdata,channel_reestablish,channel_id,channel_id,
msgdata,channel_reestablish,next_commitment_number,u64,
msgdata,channel_reestablish,next_revocation_number,u64,
msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect
msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect
msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32,option_data_loss_protect,option_static_remotekey
msgdata,channel_reestablish,my_current_per_commitment_point,point,,option_data_loss_protect,option_static_remotekey
msgtype,announcement_signatures,259
msgdata,announcement_signatures,channel_id,channel_id,
msgdata,announcement_signatures,short_channel_id,short_channel_id,

Loading…
Cancel
Save