Skip to content

Commit

Permalink
global: remove tags from BOLT quotes now dual-funding is in master
Browse files Browse the repository at this point in the history
A few of them had minor wording changes, too.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Feb 17, 2024
1 parent fa8c600 commit 54f09f7
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 140 deletions.
22 changes: 14 additions & 8 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -2612,7 +2612,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 @@ -2850,18 +2850,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
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
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
38 changes: 19 additions & 19 deletions common/interactivetx.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
#include <common/wire_error.h>

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - if has received 4096 `tx_add_input` messages during this negotiation
*/
#define MAX_TX_ADD_INPUT_MSG_RCVD 4096
/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - it has received 4096 `tx_add_output` messages during this negotiation
*/
#define MAX_TX_ADD_OUTPUT_MSG_RCVD 4096

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - there are more than 252 inputs
Expand Down Expand Up @@ -427,7 +427,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
tal_hex(ctx, msg));

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - if has received 4096 `tx_add_input`
Expand All @@ -438,7 +438,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
" received %d",
MAX_TX_ADD_INPUT_MSG_RCVD);
/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the `serial_id` has the wrong parity
Expand All @@ -448,7 +448,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
"Invalid serial_id rcvd. %"PRIu64,
serial_id);
/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the `serial_id` is already included in
Expand Down Expand Up @@ -487,9 +487,9 @@ char *process_interactivetx_updates(const tal_t *ctx,
tx));

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if:
* - MUST fail the negotiation if:...
* - the `prevtx` and `prevtx_vout` are
* identical to a previously added (and not
* removed) input's
Expand All @@ -504,7 +504,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
&outpoint));

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - there are more than 252 inputs
Expand All @@ -516,7 +516,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
MAX_FUNDING_INPUTS);

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node:
* - MUST add all received inputs to the transaction
*/
Expand Down Expand Up @@ -547,7 +547,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
"Parsing tx_remove_input %s",
tal_hex(ctx, msg));

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the input or output identified by the
Expand All @@ -560,7 +560,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
"serial_id: %"PRIu64,
serial_id);

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the `serial_id` does not correspond
Expand Down Expand Up @@ -590,7 +590,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
tal_hex(ctx, msg));

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - it has received 4096 `tx_add_output`
Expand All @@ -602,7 +602,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
" received (%d)",
MAX_TX_ADD_OUTPUT_MSG_RCVD);

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the `serial_id` has the wrong parity
Expand All @@ -612,7 +612,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
"Invalid serial_id rcvd. %"PRIu64,
serial_id);

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the `serial_id` is already included
Expand All @@ -623,15 +623,15 @@ char *process_interactivetx_updates(const tal_t *ctx,
" %"PRIu64, serial_id);
amt = amount_sat(value);

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* The receiving node: ...
* - MAY fail the negotiation if `script`
* is non-standard */
if (!is_known_scripttype(scriptpubkey))
return tal_fmt(ctx, "Script is not standard");

/*
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - there are more than 252 outputs
Expand Down Expand Up @@ -659,7 +659,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
"Parsing tx_remove_output %s",
tal_hex(ctx, msg));

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the input or output identified by the
Expand All @@ -672,7 +672,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
"serial_id: %"PRIu64,
serial_id);

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* The receiving node: ...
* - MUST fail the negotiation if: ...
* - the `serial_id` does not correspond to a
Expand Down
8 changes: 3 additions & 5 deletions common/psbt_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,18 @@ psbt_to_witnesses(const tal_t *ctx,
if (input_index_to_ignore == i)
continue;

/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
/* BOLT #2:
* - if is the *initiator*:
* - MUST send even `serial_id`s
*/
if (wtx_s && serial_id % 2 == side_to_stack) {

/* BOLT-e299850cb5ebd8bd9c55763bbc498fcdf94a9567 #2:
/* BOLT #2:
*
* The `witness_data` is encoded as per bitcoin's
* wire protocol (a CompactSize number of elements,
* with each element a CompactSize length and that
* many bytes following. Each `witness_data` field
* contains all of the witness elements for a single input,
* including the leading counter of elements.
* many bytes following).
*/
struct witness *wit = tal(witnesses, struct witness);
wit->witness_data = tal_arr(wit, u8, 0);
Expand Down
8 changes: 4 additions & 4 deletions connectd/multiplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,11 @@ static struct pubkey *extract_revocation_basepoint(const tal_t *ctx,

switch (t) {
case WIRE_OPEN_CHANNEL2:
/* BOLT-dualfund #2:
/* BOLT #2:
* 1. type: 64 (`open_channel2`)
* 2. data:
* * [`chain_hash`:`chain_hash`]
* * [`channel_id`:`zerod_channel_id`]
* * [`channel_id`:`temporary_channel_id`]
* * [`u32`:`funding_feerate_perkw`]
* * [`u32`:`commitment_feerate_perkw`]
* * [`u64`:`funding_satoshis`]
Expand Down Expand Up @@ -838,10 +838,10 @@ static struct pubkey *extract_revocation_basepoint(const tal_t *ctx,
+ PUBKEY_CMPR_LEN);
break;
case WIRE_ACCEPT_CHANNEL2:
/* BOLT-dualfund #2:
/* BOLT #2:
* 1. type: 65 (`accept_channel2`)
* 2. data:
* * [`channel_id`:`zerod_channel_id`]
* * [`channel_id`:`temporary_channel_id`]
* * [`u64`:`funding_satoshis`]
* * [`u64`:`dust_limit_satoshis`]
* * [`u64`:`max_htlc_value_in_flight_msat`]
Expand Down
4 changes: 0 additions & 4 deletions lightningd/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@ struct channel *new_unsaved_channel(struct peer *peer,
ld->our_features,
peer->their_features);

/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9
* | 222/223 | `option_dual_fund`
* | Use v2 of channel open, enables dual funding
* | IN9 */
channel->static_remotekey_start[LOCAL]
= channel->static_remotekey_start[REMOTE] = 0;

Expand Down
Loading

0 comments on commit 54f09f7

Please sign in to comment.