Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOLT catchup, including dual funding! #7086

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CCANDIR := ccan

# Where we keep the BOLT RFCs
BOLTDIR := ../bolts/
DEFAULT_BOLTVERSION := 6e85df448bfee7d10f26aabb06b8eba3d7505888
DEFAULT_BOLTVERSION := 0bdaa8b9f65fc82a178d0d8722d352f2320b02f4
# Can be overridden on cmdline.
BOLTVERSION := $(DEFAULT_BOLTVERSION)

Expand Down
22 changes: 14 additions & 8 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ static void handle_unexpected_reestablish(struct peer *peer, const u8 *msg)

static bool is_initiators_serial(const struct wally_map *unknowns)
{
/* BOLT-f15b6b0feeffc2acd1a8466537810bbb3f824f9f #2:
/* BOLT #2:
* The sending node: ...
* - if is the *initiator*:
* - MUST send even `serial_id`s
Expand Down Expand Up @@ -2824,18 +2824,24 @@ static size_t calc_weight(enum tx_role role, const struct wally_psbt *psbt)
{
size_t weight = 0;

/* BOLT-0d8b701614b09c6ee4172b04da2203e73deec7e2 #2:
* The initiator:
* ...
* - MUST pay for the common fields.
/* BOLT #2:
* The *initiator* is responsible for paying the fees for the following fields,
* to be referred to as the `common fields`.
*
* - version
* - segwit marker + flag
* - input count
* - output count
* - locktime
*/
if (role == TX_INITIATOR)
weight += bitcoin_tx_core_weight(psbt->num_inputs,
psbt->num_outputs);

/* BOLT-0d8b701614b09c6ee4172b04da2203e73deec7e2 #2:
* Each node:
* - MUST pay for their own added inputs and outputs.
/* BOLT #2:
* The rest of the transaction bytes' fees are the responsibility of
* the peer who contributed that input or output via `tx_add_input` or
* `tx_add_output`, at the agreed upon `feerate`.
*/
for (size_t i = 0; i < psbt->num_inputs; i++)
if (is_initiators_serial(&psbt->inputs[i].unknowns)) {
Expand Down
2 changes: 1 addition & 1 deletion channeld/test/run-commit_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ int main(int argc, const char *argv[])
* In the following:
* - *local* transactions are considered, which implies that all
* payments to *local* are delayed.
* - It's assumed that *local* is the funder.
* - It's assumed that *local* is the opener.
* - Private keys are displayed as 32 bytes plus a trailing 1
* (Bitcoin's convention for "compressed" private keys, i.e. keys for
* which the public key is compressed).
Expand Down
2 changes: 1 addition & 1 deletion channeld/test/run-full_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ int main(int argc, const char *argv[])
* In the following:
* - *local* transactions are considered, which implies that all
* payments to *local* are delayed.
* - It's assumed that *local* is the funder.
* - It's assumed that *local* is the opener.
* - Private keys are displayed as 32 bytes plus a trailing 1
* (Bitcoin's convention for "compressed" private keys, i.e. keys for
* which the public key is compressed).
Expand Down
4 changes: 2 additions & 2 deletions common/blindedpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static u8 *decrypt_encmsg_raw(const tal_t *ctx,
*/
subkey_from_hmac("rho", ss, &rho);

/* BOLT-onion-message #4:
/* BOLT #4:
*- If the `encrypted_data` field is missing or cannot
* be decrypted:
* - MUST return an error
Expand Down Expand Up @@ -204,7 +204,7 @@ struct tlv_encrypted_data_tlv *decrypt_encrypted_data(const tal_t *ctx,
const u8 *cursor = decrypt_encmsg_raw(tmpctx, blinding, ss, enctlv);
size_t maxlen = tal_bytelen(cursor);

/* BOLT-onion-message #4:
/* BOLT #4:
*
* - MUST return an error if `encrypted_recipient_data` does not decrypt
* using the blinding point as described in
Expand Down
3 changes: 2 additions & 1 deletion common/blindedpay.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ u8 **blinded_onion_hops(const tal_t *ctx,
bool first = (i == 0);
bool final = (i == tal_count(onions) - 1);

/* BOLT-blinded-payments #4:
/* BOLT #4:
* - For every node inside a blinded route:
* - MUST include the `encrypted_recipient_data` provided by the
* recipient
Expand All @@ -27,6 +27,7 @@ u8 **blinded_onion_hops(const tal_t *ctx,
* recipient in `current_blinding_point`
* - If it is the final node:
* - MUST include `amt_to_forward`, `outgoing_cltv_value` and `total_amount_msat`.
*...
* - MUST NOT include any other tlv field.
*/
onions[i] = onion_blinded_hop(onions,
Expand Down
6 changes: 3 additions & 3 deletions common/channel_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct channel_config {
/* BOLT #2:
*
* `max_htlc_value_in_flight_msat` is a cap on total value of
* outstanding HTLCs, which allows a node to limit its exposure to
* HTLCs */
* outstanding HTLCs offered by the remote node, which allows the
* local node to limit its exposure to HTLCs */
struct amount_msat max_htlc_value_in_flight;

/* BOLT #2:
Expand All @@ -69,7 +69,7 @@ struct channel_config {
/* BOLT #2:
*
* similarly, `max_accepted_htlcs` limits the number of outstanding
* HTLCs the other node can offer. */
* HTLCs the remote node can offer. */
u16 max_accepted_htlcs;

/* BOLT-TBD #X
Expand Down
17 changes: 8 additions & 9 deletions common/channel_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ void derive_channel_id_v2(struct channel_id *channel_id,
const struct pubkey *basepoint_1,
const struct pubkey *basepoint_2)
{
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* `channel_id`, v2
* For channels established using the v2 protocol, the
* `channel_id` is the
* SHA256(lesser-revocation-basepoint ||
* greater-revocation-basepoint),
* `SHA256(lesser-revocation-basepoint ||
* greater-revocation-basepoint)`,
* where the lesser and greater is based off the order of
* the basepoint. The basepoints are compact
* DER-encoded public keys.
* the basepoint.
*/
u8 der_keys[PUBKEY_CMPR_LEN * 2];
struct sha256 sha;
Expand All @@ -53,10 +52,10 @@ void derive_tmp_channel_id(struct channel_id *channel_id,
{
struct sha256 sha;

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* If the peer's revocation basepoint is unknown
* (e.g. `open_channel2`), a temporary `channel_id` should be
* found by using a zeroed out basepoint for the unknown peer.
/* BOLT #2:
* When sending `open_channel2`, the peer's revocation basepoint is unknown.
* A `temporary_channel_id` must be computed by using a zeroed out basepoint
* for the non-initiator.
*/
u8 der_keys[PUBKEY_CMPR_LEN * 2];
memset(der_keys, 0, PUBKEY_CMPR_LEN);
Expand Down
2 changes: 1 addition & 1 deletion common/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static const struct feature_style feature_styles[] = {
{ OPT_DUAL_FUND,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_DONT_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
/* FIXME: Currently not explicitly signalled, but we do
* support it for zeroconf */
Expand Down
29 changes: 9 additions & 20 deletions common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
#define COMPULSORY_FEATURE(x) ((x) & 0xFFFFFFFE)
#define OPTIONAL_FEATURE(x) ((x) | 1)

/* BOLT-a526652801a541ed33b34d000a3b686a857c811f #9:
/* BOLT #9:
*
* | Bits | Name |...
* | 0/1 | `option_data_loss_protect` |... IN ...
Expand All @@ -116,9 +116,12 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
* | 22/23 | `option_anchors_zero_fee_htlc_tx` |... IN ...
* | 24/25 | `option_route_blinding` |...IN9 ...
* | 26/27 | `option_shutdown_anysegwit` |... IN ...
* | 28/29 | `option_dual_fund` |... IN ...
* | 38/39 | `option_onion_messages` |... IN ...
* | 44/45 | `option_channel_type` |... IN ...
* | 46/47 | `option_scid_alias` | ... IN ...
* | 48/49 | `option_payment_metadata` |... 9 ...
* | 62/63 | `option_splice` |... IN ...
* | 50/51 | `option_zeroconf` | ... IN ...
*/
#define OPT_DATA_LOSS_PROTECT 0
#define OPT_INITIAL_ROUTING_SYNC 2
Expand All @@ -134,38 +137,24 @@ struct feature_set *feature_set_dup(const tal_t *ctx,
#define OPT_ANCHORS_ZERO_FEE_HTLC_TX 22
#define OPT_ROUTE_BLINDING 24
#define OPT_SHUTDOWN_ANYSEGWIT 26
#define OPT_DUAL_FUND 28
#define OPT_ONION_MESSAGES 38
#define OPT_CHANNEL_TYPE 44
#define OPT_SCID_ALIAS 46
#define OPT_PAYMENT_METADATA 48
#define OPT_ZEROCONF 50

/* BOLT-splice #9:
* | 62/63 | `option_splice` | ... IN ...
*/
#define OPT_SPLICE 62
#define OPT_EXPERIMENTAL_SPLICE 162

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #9:
* | 28/29 | `option_dual_fund` | ... IN9 ...
*/
#define OPT_DUAL_FUND 28

/* BOLT-519be05f61e2c35ddf95b731203f89b4ee0946c3 #9:
* | 46/47 | `option_scid_alias` | ... IN ...
* | 50/51 | `option_eroconf` | ... IN ...
*/
#define OPT_SCID_ALIAS 46
#define OPT_ZEROCONF 50

/* BOLT-quiescent #9:
* | 34/35 | `option_quiesce` | ... IN ...
*/
#define OPT_QUIESCE 34

/* BOLT-offers #9:
*
* | 38/39 | `option_onion_messages` |... IN ...
*/
#define OPT_ONION_MESSAGES 38

#define OPT_SHUTDOWN_WRONG_FUNDING 104

/* BOLT-peer-storage #9:
Expand Down
2 changes: 1 addition & 1 deletion common/gossip_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* only onion tlv payloads. */
#define ROUTING_MAX_HOPS 20

/* BOLT-f3a9f7f4e9e7a5a2997f3129e13d94090091846a #7:
/* BOLT #7:
*
* The `channel_flags` bitfield...individual bits:
*...
Expand Down
Loading
Loading