diff --git a/bitcoin/script.c b/bitcoin/script.c index f4535f4aa..b7a043b01 100644 --- a/bitcoin/script.c +++ b/bitcoin/script.c @@ -627,12 +627,12 @@ u8 **bitcoin_witness_htlc(const tal_t *ctx, * * OP_IF * # Penalty transaction - * + * * OP_ELSE - * `to-self-delay` + * `to_self_delay` * OP_CSV * OP_DROP - * + * * OP_ENDIF * OP_CHECKSIG */ @@ -660,10 +660,10 @@ u8 **bitcoin_to_local_spend_delayedkey(const tal_t *ctx, /* BOLT #3: * * It is spent by a transaction with `nSequence` field set to - * `to-self-delay` (which can only be valid after that duration has + * `to_self_delay` (which can only be valid after that duration has * passed), and witness: * - * 0 + * 0 */ u8 **witness = tal_arr(ctx, u8 *, 3); @@ -682,7 +682,7 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx, * If a revoked commitment transaction is published, the other party * can spend this output immediately with the following witness: * - * 1 + * 1 */ u8 **witness = tal_arr(ctx, u8 *, 3); @@ -702,7 +702,7 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx, * key. The output is a P2WSH, with a witness script: * * # To you with revocation key - * OP_DUP OP_HASH160 OP_EQUAL + * OP_DUP OP_HASH160 OP_EQUAL * OP_IF * OP_CHECKSIG * OP_ELSE @@ -712,7 +712,7 @@ u8 **bitcoin_to_local_spend_revocation(const tal_t *ctx, * OP_DROP 2 OP_SWAP 2 OP_CHECKMULTISIG * OP_ELSE * # To you with preimage. - * OP_HASH160 OP_EQUALVERIFY + * OP_HASH160 OP_EQUALVERIFY * OP_CHECKSIG * OP_ENDIF * OP_ENDIF @@ -767,7 +767,7 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, * payment preimage. The output is a P2WSH, with a witness script: * * # To you with revocation key - * OP_DUP OP_HASH160 OP_EQUAL + * OP_DUP OP_HASH160 OP_EQUAL * OP_IF * OP_CHECKSIG * OP_ELSE @@ -775,11 +775,11 @@ u8 *bitcoin_wscript_htlc_offer(const tal_t *ctx, * OP_SIZE 32 OP_EQUAL * OP_IF * # To me via HTLC-success transaction. - * OP_HASH160 OP_EQUALVERIFY + * OP_HASH160 OP_EQUALVERIFY * 2 OP_SWAP 2 OP_CHECKMULTISIG * OP_ELSE * # To you after timeout. - * OP_DROP OP_CHECKLOCKTIMEVERIFY OP_DROP + * OP_DROP OP_CHECKLOCKTIMEVERIFY OP_DROP * OP_CHECKSIG * OP_ENDIF * OP_ENDIF @@ -834,7 +834,7 @@ u8 *bitcoin_wscript_htlc_receive(const tal_t *ctx, * ## HTLC-Timeout and HTLC-Success Transactions * *... - * * `txin[0]` witness stack: `0 ` for HTLC-Success, `0 0` for HTLC-Timeout. + * * `txin[0]` witness stack: `0 ` for HTLC-Success, `0 0` for HTLC-Timeout. */ u8 **bitcoin_htlc_offer_spend_timeout(const tal_t *ctx, const secp256k1_ecdsa_signature *localsig, @@ -882,12 +882,12 @@ u8 *bitcoin_wscript_htlc_tx(const tal_t *ctx, * * OP_IF * # Penalty transaction - * + * * OP_ELSE - * `to-self-delay` + * `to_self_delay` * OP_CSV * OP_DROP - * + * * OP_ENDIF * OP_CHECKSIG */ diff --git a/daemon/routing.c b/daemon/routing.c index 729fabb01..1d839e0be 100644 --- a/daemon/routing.c +++ b/daemon/routing.c @@ -551,9 +551,9 @@ bool add_channel_direction(struct routing_state *rstate, * * The following `address descriptor` types are defined: * - * 1. `0`: padding. data = none (length 0). - * 1. `1`: IPv4. data = `[4:ipv4-addr][2:port]` (length 6) - * 2. `2`: IPv6. data = `[16:ipv6-addr][2:port]` (length 18) + * * `0`: padding. data = none (length 0). + * * `1`: ipv4. data = `[4:ipv4_addr][2:port]` (length 6) + * * `2`: ipv6. data = `[16:ipv6_addr][2:port]` (length 18) */ /* FIXME: Don't just take first one, depends whether we have IPv6 ourselves */ @@ -622,7 +622,7 @@ bool read_ip(const tal_t *ctx, const u8 *addresses, char **hostname, * used for aligning fields following `addresses`. * * The creating node MUST NOT create a type 1 or type 2 address descriptor - * with `port` equal to zero, and SHOULD ensure `ipv4-addr` and `ipv6-addr` + * with `port` equal to zero, and SHOULD ensure `ipv4_addr` and `ipv6_addr` * are routable addresses. The creating node MUST NOT include more than one * `address descriptor` of the same type. */ diff --git a/daemon/sphinx.h b/daemon/sphinx.h index 28e255045..c8ad024be 100644 --- a/daemon/sphinx.h +++ b/daemon/sphinx.h @@ -35,7 +35,7 @@ enum route_next_case { ONION_FORWARD = 1, }; -/* BOLT #4: +/* FIXME-OLD #4: * * The format of the per-hop-payload for a version 0 packet is as follows: ``` diff --git a/lightningd/channel.c b/lightningd/channel.c index 112ceec13..ea7922a34 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -338,7 +338,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel, /* BOLT #2: * * A receiving node SHOULD fail the channel if a sending node... sets - * `cltv-expiry` to greater or equal to 500000000. + * `cltv_expiry` to greater or equal to 500000000. */ if (!blocks_to_abs_locktime(cltv_expiry, &htlc->expiry)) return CHANNEL_ERR_INVALID_EXPIRY; @@ -349,12 +349,12 @@ enum channel_add_err channel_add_htlc(struct channel *channel, * * 1. type: 128 (`update_add_htlc`) * 2. data: - * * [32:channel-id] - * * [8:id] - * * [4:amount-msat] - * * [4:cltv-expiry] - * * [32:payment-hash] - * * [1366:onion-routing-packet] + * * [`32`:`channel_id`] + * * [`8`:`id`] + * * [`4`:`amount_msat`] + * * [`4`:`cltv_expiry`] + * * [`32`:`payment_hash`] + * * [`1366`:`onion_routing_packet`] */ htlc->routing = tal_dup_arr(htlc, u8, routing, TOTAL_PACKET_SIZE, 0); @@ -379,7 +379,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel, /* BOLT #2: * * A receiving node SHOULD fail the channel if it receives an - * `amount-sat` equal to zero, below its own `htlc-minimum-msat`, + * `amount_msat` equal to zero, below its own `htlc_minimum_msat`, * or... */ if (htlc->msatoshi == 0) { @@ -398,7 +398,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel, /* BOLT #2: * * A receiving node SHOULD fail the channel if a sending node - * adds more than its `max-accepted-htlcs` HTLCs to its local + * adds more than its `max_accepted_htlcs` HTLCs to its local * commitment transaction */ if (tal_count(committed) - tal_count(removing) + tal_count(adding) > max_accepted_htlcs(channel, recipient)) { @@ -413,7 +413,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel, /* BOLT #2: * * A receiving node SHOULD fail the channel if a sending node ... or - * adds more than its `max-htlc-value-in-flight-msat` worth of offered + * adds more than its `max_htlc_value_in_flight_msat` worth of offered * HTLCs to its local commitment transaction */ if (msat_in_htlcs > max_htlc_value_in_flight_msat(channel, recipient)) { e = CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED; @@ -422,8 +422,8 @@ enum channel_add_err channel_add_htlc(struct channel *channel, /* BOLT #2: * - * or which the sending node cannot afford at the current `fee-rate` - * while maintaining its channel reserve. + * or which the sending node cannot afford at the current + * `feerate_per_kw` while maintaining its channel reserve. */ if (channel->funder == htlc_owner(htlc)) { u64 feerate = view->feerate_per_kw; @@ -498,9 +498,9 @@ enum channel_remove_err channel_fulfill_htlc(struct channel *channel, sha256(&hash, preimage, sizeof(*preimage)); /* BOLT #2: * - * A receiving node MUST check that the `payment-preimage` value in - * `update-fulfill_htlc` SHA256 hashes to the corresponding HTLC - * `payment-hash`, and MUST fail the channel if it does not. + * A receiving node MUST check that the `payment_preimage` value in + * `update_fulfill_htlc` SHA256 hashes to the corresponding HTLC + * `payment_hash`, and MUST fail the channel if it does not. */ if (!structeq(&hash, &htlc->rhash)) return CHANNEL_ERR_BAD_PREIMAGE; diff --git a/lightningd/channel.h b/lightningd/channel.h index 4fea6397d..1d498f25d 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -64,7 +64,7 @@ struct channel { /* BOLT #2: * - * `dust-limit-satoshis` is the threshold below which output should be + * `dust_limit_satoshis` is the threshold below which output should be * generated for this node's commitment or HTLC transaction */ static inline u64 dust_limit_satoshis(const struct channel *channel, enum side side) @@ -73,7 +73,7 @@ static inline u64 dust_limit_satoshis(const struct channel *channel, } /* BOLT #2: * - * `max-htlc-value-in-inflight-msat` is a cap on total value of + * `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 */ static inline u64 max_htlc_value_in_flight_msat(const struct channel *channel, @@ -83,7 +83,7 @@ static inline u64 max_htlc_value_in_flight_msat(const struct channel *channel, } /* BOLT #2: * - * similarly `max-accepted-htlcs` limits the number of outstanding + * similarly `max_accepted_htlcs` limits the number of outstanding * HTLCs the other node can offer. */ static inline u16 max_accepted_htlcs(const struct channel *channel, enum side recipient) @@ -92,7 +92,7 @@ static inline u16 max_accepted_htlcs(const struct channel *channel, } /* BOLT #2: * - * `channel-reserve-satoshis` is the minimum amount that the other + * `channel_reserve_satoshis` is the minimum amount that the other * node is to keep as a direct payment. */ static inline u64 channel_reserve_msat(const struct channel *channel, enum side side) @@ -101,7 +101,7 @@ static inline u64 channel_reserve_msat(const struct channel *channel, } /* BOLT #2: * - * `htlc-minimum-msat` indicates the smallest value HTLC this node will accept. + * `htlc_minimum_msat` indicates the smallest value HTLC this node will accept. */ static inline u32 htlc_minimum_msat(const struct channel *channel, enum side recipient) @@ -110,7 +110,7 @@ static inline u32 htlc_minimum_msat(const struct channel *channel, } /* BOLT #2: * - * `to-self-delay` is the number of blocks that the other nodes + * `to_self_delay` is the number of blocks that the other nodes * to-self outputs must be delayed, using `OP_CHECKSEQUENCEVERIFY` * delays */ static inline u16 to_self_delay(const struct channel *channel, enum side side) diff --git a/lightningd/channel/channel.c b/lightningd/channel/channel.c index f0264aa63..2657a91eb 100644 --- a/lightningd/channel/channel.c +++ b/lightningd/channel/channel.c @@ -408,7 +408,7 @@ static void send_commit(struct peer *peer) /* BOLT #2: * - * A node MUST include one `htlc-signature` for every HTLC transaction + * A node MUST include one `htlc_signature` for every HTLC transaction * corresponding to BIP69 lexicographic ordering of the commitment * transaction. */ @@ -519,7 +519,7 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg) /* BOLT #2: * - * A receiving node MUST fail the channel if `num-htlcs` is not equal + * A receiving node MUST fail the channel if `num_htlcs` is not equal * to the number of HTLC outputs in the local commitment transaction * once all pending updates are applied. */ @@ -534,7 +534,7 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg) /* BOLT #2: * * A receiving node MUST fail - * the channel if any `htlc-signature` is not valid for the + * the channel if any `htlc_signature` is not valid for the * corresponding HTLC transaction. */ for (i = 0; i < tal_count(htlc_sigs); i++) { @@ -701,8 +701,8 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg) /* BOLT #2: * - * A receiving node MUST check that `per-commitment-secret` generates - * the previous `per-commitment-point`, and MUST fail if it does + * A receiving node MUST check that `per_commitment_secret` generates + * the previous `per_commitment_point`, and MUST fail if it does * not. */ memcpy(&privkey, &old_commit_secret, sizeof(privkey)); @@ -727,7 +727,7 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg) /* BOLT #2: * - * A receiving node MAY fail if the `per-commitment-secret` was not + * A receiving node MAY fail if the `per_commitment_secret` was not * generated by the protocol in [BOLT #3] */ if (!shachain_add_hash(&peer->their_shachain, diff --git a/lightningd/channel_config.h b/lightningd/channel_config.h index 4c3526d5d..fb10b77ec 100644 --- a/lightningd/channel_config.h +++ b/lightningd/channel_config.h @@ -8,28 +8,28 @@ * * 1. type: 32 (`open_channel`) * 2. data: - * * [32:chain-hash] - * * [32:temporary-channel-id] - * * [8:funding-satoshis] - * * [8:push-msat] - * * [8:dust-limit-satoshis] - * * [8:max-htlc-value-in-flight-msat] - * * [8:channel-reserve-satoshis] - * * [4:htlc-minimum-msat] - * * [4:feerate-per-kw] - * * [2:to-self-delay] - * * [2:max-accepted-htlcs] + * * [`32`:`chain_hash`] + * * [`32`:`temporary_channel_id`] + * * [`8`:`funding_satoshis`] + * * [`8`:`push_msat`] + * * [`8`:`dust_limit_satoshis`] + * * [`8`:`max_htlc_value_in_flight_msat`] + * * [`8`:`channel_reserve_satoshis`] + * * [`4`:`htlc_minimum_msat`] + * * [`4`:`feerate_per_kw`] + * * [`2`:`to_self_delay`] + * * [`2`:`max_accepted_htlcs`] *... * 1. type: 33 (`accept_channel`) * 2. data: - * * [32:temporary-channel-id] - * * [8:dust-limit-satoshis] - * * [8:max-htlc-value-in-flight-msat] - * * [8:channel-reserve-satoshis] - * * [4:minimum-depth] - * * [4:htlc-minimum-msat] - * * [2:to-self-delay] - * * [2:max-accepted-htlcs] + * * [`32`:`temporary_channel_id`] + * * [`8`:`dust_limit_satoshis`] + * * [`8`:`max_htlc_value_in_flight_msat`] + * * [`8`:`channel_reserve_satoshis`] + * * [`4`:`minimum_depth`] + * * [`4`:`htlc_minimum_msat`] + * * [`2`:`to_self_delay`] + * * [`2`:`max_accepted_htlcs`] */ struct channel_config { u64 dust_limit_satoshis; diff --git a/lightningd/commit_tx.c b/lightningd/commit_tx.c index d80194b09..1eba6c04e 100644 --- a/lightningd/commit_tx.c +++ b/lightningd/commit_tx.c @@ -15,7 +15,7 @@ * The 48-bit commitment transaction number is obscured by `XOR` with * the lower 48 bits of: * - * SHA256(payment-basepoint from open_channel || payment-basepoint from accept_channel) + * SHA256(payment_basepoint from open_channel || payment_basepoint from accept_channel) */ u64 commit_number_obscurer(const struct pubkey *opener_payment_basepoint, const struct pubkey *accepter_payment_basepoint) @@ -55,7 +55,7 @@ u64 htlc_timeout_fee(u64 feerate_per_kw) * * The fee for an HTLC-timeout transaction MUST BE calculated to match: * - * 1. Multiply `feerate-per-kw` by 663 and divide by 1000 (rounding + * 1. Multiply `feerate_per_kw` by 663 and divide by 1000 (rounding * down). */ return feerate_per_kw * 663 / 1000; @@ -67,7 +67,7 @@ u64 htlc_success_fee(u64 feerate_per_kw) * * The fee for an HTLC-success transaction MUST BE calculated to match: * - * 1. Multiply `feerate-per-kw` by 703 and divide by 1000 (rounding + * 1. Multiply `feerate_per_kw` by 703 and divide by 1000 (rounding * down). */ return feerate_per_kw * 703 / 1000; @@ -82,7 +82,7 @@ static bool trim(const struct htlc *htlc, /* BOLT #3: * * For every offered HTLC, if the HTLC amount minus the HTLC-timeout - * fee would be less than `dust-limit-satoshis` set by the transaction + * fee would be less than `dust_limit_satoshis` set by the transaction * owner, the commitment transaction MUST NOT contain that output, * otherwise it MUST be generated as specified in [Offered HTLC * Outputs](#offered-htlc-outputs). @@ -92,7 +92,7 @@ static bool trim(const struct htlc *htlc, /* BOLT #3: * * For every received HTLC, if the HTLC amount minus the HTLC-success - * fee would be less than `dust-limit-satoshis` set by the transaction + * fee would be less than `dust_limit_satoshis` set by the transaction * owner, the commitment transaction MUST NOT contain that output, * otherwise it MUST be generated as specified in [Received HTLC * Outputs](#received-htlc-outputs). @@ -138,7 +138,7 @@ u64 commit_tx_base_fee(u64 feerate_per_kw, size_t num_untrimmed_htlcs) /* BOLT #3: * - * 3. Multiply `feerate-per-kw` by `weight`, divide by 1000 + * 3. Multiply `feerate_per_kw` by `weight`, divide by 1000 * (rounding down). */ return feerate_per_kw * weight / 1000; @@ -225,8 +225,8 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx, /* BOLT #3: * - * 3. Subtract this base fee from the funder (either `to-local` or - * `to-remote`), with a floor of zero (see [Fee Payment](#fee-payment)). + * 3. Subtract this base fee from the funder (either `to_local` or + * `to_remote`), with a floor of zero (see [Fee Payment](#fee-payment)). */ subtract_fee(funder, side, base_fee_msat, &self_pay_msat, &other_pay_msat); @@ -294,8 +294,8 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx, /* BOLT #3: * - * 5. If the `to-local` amount is greater or equal to - * `dust-limit-satoshis`, add a [To-Local + * 5. If the `to_local` amount is greater or equal to + * `dust_limit_satoshis`, add a [`to_local` * Output](#to-local-output). */ if (self_pay_msat / 1000 >= dust_limit_satoshis) { @@ -315,14 +315,14 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx, /* BOLT #3: * - * 6. If the `to-remote` amount is greater or equal to - * `dust-limit-satoshis`, add a [To-Remote + * 6. If the `to_remote` amount is greater or equal to + * `dust_limit_satoshis`, add a [`to_remote` * Output](#to-remote-output). */ if (other_pay_msat / 1000 >= dust_limit_satoshis) { /* BOLT #3: * - * #### To-Remote Output + * #### `to_remote` Output * * This output sends funds to the other peer, thus is a simple * P2WPKH to `remotekey`. diff --git a/lightningd/commit_tx.h b/lightningd/commit_tx.h index 1e874264e..5c9b7b183 100644 --- a/lightningd/commit_tx.h +++ b/lightningd/commit_tx.h @@ -10,7 +10,7 @@ struct sha256_double; * * This obscures the number of commitments made on the channel in the * case of unilateral close, yet still provides a useful index for - * both nodes (who know the payment-basepoints) to quickly find a + * both nodes (who know the `payment_basepoint`s) to quickly find a * revoked commitment transaction. */ u64 commit_number_obscurer(const struct pubkey *opener_payment_basepoint, diff --git a/lightningd/cryptomsg.c b/lightningd/cryptomsg.c index df5cdf32b..0bbb46c85 100644 --- a/lightningd/cryptomsg.c +++ b/lightningd/cryptomsg.c @@ -167,7 +167,7 @@ bool cryptomsg_decrypt_header(struct crypto_state *cs, u8 hdr[18], u16 *lenp) * * * Let the encrypted length prefix be known as `lc` * - * * Decrypt `lc` using `ChaCha20-Poy1305`, `rn`, and `rk` to + * * Decrypt `lc` using `ChaCha20-Poly1305`, `rn`, and `rk` to * obtain size of the encrypted packet `l`. * * A zero-length byte slice is to be passed as the AD * (associated data). diff --git a/lightningd/derive_basepoints.c b/lightningd/derive_basepoints.c index 9971c9445..834f0654a 100644 --- a/lightningd/derive_basepoints.c +++ b/lightningd/derive_basepoints.c @@ -54,9 +54,9 @@ bool derive_basepoints(const struct privkey *seed, /* BOLT #3: * - * The `per-commitment-point` is generated using EC multiplication: + * The `per_commitment_point` is generated using EC multiplication: * - * per-commitment-point = per-commitment-secret * G + * per_commitment_point = per_commitment_secret * G */ if (per_commit_point) { if (secp256k1_ec_pubkey_create(secp256k1_ctx, @@ -89,9 +89,9 @@ bool next_per_commit_point(const struct sha256 *shaseed, /* BOLT #3: * - * The `per-commitment-point` is generated using EC multiplication: + * The `per_commitment_point` is generated using EC multiplication: * - * per-commitment-point = per-commitment-secret * G + * per_commitment_point = per_commitment_secret * G */ if (secp256k1_ec_pubkey_create(secp256k1_ctx, &per_commit_point->pubkey, diff --git a/lightningd/handshake/handshake.c b/lightningd/handshake/handshake.c index e35d61e80..0108d369f 100644 --- a/lightningd/handshake/handshake.c +++ b/lightningd/handshake/handshake.c @@ -228,7 +228,7 @@ static struct handshake *new_handshake(const tal_t *ctx, * * 1. `h = SHA-256(protocolName)` * * where `protocolName = "Noise_XK_secp256k1_ChaChaPoly_SHA256"` - * encoded as an ascii string. + * encoded as an ASCII string. */ sha256(&handshake->h, "Noise_XK_secp256k1_ChaChaPoly_SHA256", strlen("Noise_XK_secp256k1_ChaChaPoly_SHA256")); @@ -245,7 +245,7 @@ static struct handshake *new_handshake(const tal_t *ctx, /* BOLT #8: * * 3. `h = SHA-256(h || prologue)` - * * where `prologue` is the ascii string: `lightning`. + * * where `prologue` is the ASCII string: `lightning`. */ sha_mix_in(&handshake->h, "lightning", strlen("lightning")); diff --git a/lightningd/htlc_tx.c b/lightningd/htlc_tx.c index e87b353b5..6e4fb65df 100644 --- a/lightningd/htlc_tx.c +++ b/lightningd/htlc_tx.c @@ -33,7 +33,7 @@ static struct bitcoin_tx *htlc_tx(const tal_t *ctx, assert(tx->version == 2); /* BOLT #3: - * * locktime: `0` for HTLC-Success, `htlc-timeout` for HTLC-Timeout. + * * locktime: `0` for HTLC-Success, `cltv_expiry` for HTLC-Timeout. */ tx->lock_time = locktime; @@ -81,7 +81,7 @@ struct bitcoin_tx *htlc_success_tx(const tal_t *ctx, u64 feerate_per_kw) { /* BOLT #3: - * * locktime: `0` for HTLC-Success, `htlc-timeout` for HTLC-Timeout. + * * locktime: `0` for HTLC-Success, `cltv_expiry` for HTLC-Timeout. */ return htlc_tx(ctx, commit_txid, commit_output_number, received_htlc, to_self_delay, revocation_pubkey, local_delayedkey, @@ -125,7 +125,7 @@ struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx, u64 feerate_per_kw) { /* BOLT #3: - * * locktime: `0` for HTLC-Success, `htlc-timeout` for HTLC-Timeout. + * * locktime: `0` for HTLC-Success, `cltv_expiry` for HTLC-Timeout. */ return htlc_tx(ctx, commit_txid, commit_output_number, offered_htlc, to_self_delay, revocation_pubkey, local_delayedkey, diff --git a/lightningd/key_derive.c b/lightningd/key_derive.c index 77d39ed60..6b0b7409e 100644 --- a/lightningd/key_derive.c +++ b/lightningd/key_derive.c @@ -7,17 +7,17 @@ /* BOLT #3: * - * ### `localkey`, `remotekey`, `local-delayedkey` and `remote-delayedkey` Derivation + * ### `localkey`, `remotekey`, `local_delayedkey` and `remote_delayedkey` Derivation * * These keys are simply generated by addition from their base points: * - * pubkey = basepoint + SHA256(per-commitment-point || basepoint)*G + * pubkey = basepoint + SHA256(per_commitment_point || basepoint)*G * - * The `localkey` uses the local node's `payment-basepoint`, `remotekey` - * uses the remote node's `payment-basepoint`, the `local-delayedkey` - * uses the local node's `delayed-payment-basepoint`, and the - * `remote-delayedkey` uses the remote node's - * `delayed-payment-basepoint`. + * The `localkey` uses the local node's `payment_basepoint`, `remotekey` + * uses the remote node's `payment_basepoint`, the `local_delayedkey` + * uses the local node's `delayed_payment_basepoint`, and the + * `remote_delayedkey` uses the remote node's + * `delayed_payment_basepoint`. */ bool derive_simple_key(const struct pubkey *basepoint, const struct pubkey *per_commitment_point, @@ -30,7 +30,7 @@ bool derive_simple_key(const struct pubkey *basepoint, pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE - printf("# SHA256(per-commitment-point || basepoint)\n"); + printf("# SHA256(per_commitment_point || basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); @@ -54,9 +54,9 @@ bool derive_simple_key(const struct pubkey *basepoint, /* BOLT #3: * * The corresponding private keys can be derived similarly if the basepoint - * secrets are known (i.e., `localkey` and `local-delayedkey` only): + * secrets are known (i.e., `localkey` and `local_delayedkey` only): * - * secretkey = basepoint-secret + SHA256(per-commitment-point || basepoint) + * secretkey = basepoint_secret + SHA256(per_commitment_point || basepoint) */ bool derive_simple_privkey(const struct secret *base_secret, const struct pubkey *basepoint, @@ -70,7 +70,7 @@ bool derive_simple_privkey(const struct secret *base_secret, pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE - printf("# SHA256(per-commitment-point || basepoint)\n"); + printf("# SHA256(per_commitment_point || basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); @@ -92,19 +92,22 @@ bool derive_simple_privkey(const struct secret *base_secret, /* BOLT #3: * - * The revocationkey is a blinded key: the remote node provides the base, - * and the local node provides the blinding factor which it later - * reveals, so the remote node can use the secret revocationkey for a - * penalty transaction. + * The `revocationkey` is a blinded key: when a node wishes to create a new + * commitment for a remote node, it uses its own `revocation_basepoint` and + * the remote node's `per_commitment_point` to derive a new `revocationkey` + * for the commitment. Once the remote node reveals (thereby revoking that + * commitment) the `per_commitment_secret` used, the node can now derive the + * `revocationsecretkey` as they now know the two secrets necessary to derive + * the key (`revocation_basepoint_secret` and `per_commitment_secret`). * - * The `per-commitment-point` is generated using EC multiplication: + * The `per_commitment_point` is generated using EC multiplication: * - * per-commitment-point = per-commitment-secret * G + * per_commitment_point = per_commitment_secret * G * * And this is used to derive the revocation key from the remote node's - * `revocation-basepoint`: + * `revocation_basepoint`: * - * revocationkey = revocation-basepoint * SHA256(revocation-basepoint || per-commitment-point) + per-commitment-point*SHA256(per-commitment-point || revocation-basepoint) + * revocationkey = revocation_basepoint * SHA256(revocation_basepoint || per_commitment_point) + per_commitment_point*SHA256(per_commitment_point || revocation_basepoint) */ bool derive_revocation_key(const struct pubkey *basepoint, const struct pubkey *per_commitment_point, @@ -119,7 +122,7 @@ bool derive_revocation_key(const struct pubkey *basepoint, pubkey_to_der(der_keys + PUBKEY_DER_LEN, per_commitment_point); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE - printf("# SHA256(revocation-basepoint || per-commitment-point)\n"); + printf("# SHA256(revocation_basepoint || per_commitment_point)\n"); printf("# => SHA256(0x%s || 0x%s)\n", tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); @@ -130,7 +133,7 @@ bool derive_revocation_key(const struct pubkey *basepoint, if (secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx, &add[0], sha.u.u8) != 1) return false; #ifdef SUPERVERBOSE - printf("# x revocation-basepoint = 0x%s\n", + printf("# x revocation_basepoint = 0x%s\n", type_to_string(tmpctx, secp256k1_pubkey, &add[0])); #endif @@ -138,7 +141,7 @@ bool derive_revocation_key(const struct pubkey *basepoint, pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE - printf("# SHA256(per-commitment-point || revocation-basepoint)\n"); + printf("# SHA256(per_commitment_point || revocation_basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); @@ -149,7 +152,7 @@ bool derive_revocation_key(const struct pubkey *basepoint, if (secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx, &add[1], sha.u.u8) != 1) return false; #ifdef SUPERVERBOSE - printf("# x per-commitment-point = 0x%s\n", + printf("# x per_commitment_point = 0x%s\n", type_to_string(tmpctx, secp256k1_pubkey, &add[1])); #endif @@ -170,10 +173,10 @@ bool derive_revocation_key(const struct pubkey *basepoint, /* BOLT #3: * - * The corresponding private key can be derived once the `per-commitment-secret` + * The corresponding private key can be derived once the `per_commitment_secret` * is known: * - * revocationsecretkey = revocation-basepoint-secret * SHA256(revocation-basepoint || per-commitment-point) + per-commitment-secret*SHA256(per-commitment-point || revocation-basepoint) + * revocationsecretkey = revocation_basepoint_secret * SHA256(revocation_basepoint || per_commitment_point) + per_commitment_secret*SHA256(per_commitment_point || revocation_basepoint) */ bool derive_revocation_privkey(const struct secret *base_secret, const struct secret *per_commitment_secret, @@ -189,7 +192,7 @@ bool derive_revocation_privkey(const struct secret *base_secret, pubkey_to_der(der_keys + PUBKEY_DER_LEN, per_commitment_point); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE - printf("# SHA256(revocation-basepoint || per-commitment-point)\n"); + printf("# SHA256(revocation_basepoint || per_commitment_point)\n"); printf("# => SHA256(0x%s || 0x%s)\n", tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); @@ -202,7 +205,7 @@ bool derive_revocation_privkey(const struct secret *base_secret, != 1) return false; #ifdef SUPERVERBOSE - printf("# * revocation-basepoint-secret (0x%s)", + printf("# * revocation_basepoint_secret (0x%s)", tal_hexstr(tmpctx, base_secret, sizeof(*base_secret))), printf("# = 0x%s\n", tal_hexstr(tmpctx, key, sizeof(*key))), #endif @@ -211,7 +214,7 @@ bool derive_revocation_privkey(const struct secret *base_secret, pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE - printf("# SHA256(per-commitment-point || revocation-basepoint)\n"); + printf("# SHA256(per_commitment_point || revocation_basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); @@ -223,7 +226,7 @@ bool derive_revocation_privkey(const struct secret *base_secret, sha.u.u8) != 1) return false; #ifdef SUPERVERBOSE - printf("# * per-commitment-secret (0x%s)", + printf("# * per_commitment_secret (0x%s)", tal_hexstr(tmpctx, per_commitment_secret, sizeof(*per_commitment_secret))), printf("# = 0x%s\n", tal_hexstr(tmpctx, &part2, sizeof(part2))); diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 1b05a19dc..458069409 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -10,7 +10,7 @@ /* BOLT #1: * * The default TCP port is 9735. This corresponds to hexadecimal - * `0x2607`, the unicode code point for LIGHTNING. + * `0x2607`, the Unicode code point for LIGHTNING. */ #define DEFAULT_PORT 0x2607 diff --git a/lightningd/opening/opening.c b/lightningd/opening/opening.c index 54daa3bb5..c0c1d763f 100644 --- a/lightningd/opening/opening.c +++ b/lightningd/opening/opening.c @@ -65,7 +65,7 @@ static void check_config_bounds(struct state *state, /* BOLT #2: * - * The receiving node MUST fail the channel if `to-self-delay` is + * The receiving node MUST fail the channel if `to_self_delay` is * unreasonably large. */ if (remoteconf->to_self_delay > state->max_to_self_delay) @@ -76,12 +76,12 @@ static void check_config_bounds(struct state *state, /* BOLT #2: * - * The receiver MAY fail the channel if `funding-satoshis` is too - * small, and MUST fail the channel if `push-msat` is greater than - * `funding-amount` * 1000. The receiving node MAY fail the channel - * if it considers `htlc-minimum-msat` too large, - * `max-htlc-value-in-flight` too small, `channel-reserve-satoshis` - * too large, or `max-accepted-htlcs` too small. + * The receiver MAY fail the channel if `funding_satoshis` is too + * small, and MUST fail the channel if `push_msat` is greater than + * `funding_satoshis` * 1000. The receiving node MAY fail the channel + * if it considers `htlc_minimum_msat` too large, + * `max_htlc_value_in_flight_msat` too small, `channel_reserve_satoshis` + * too large, or `max_accepted_htlcs` too small. */ /* We accumulate this into an effective bandwidth minimum. */ @@ -137,7 +137,7 @@ static void check_config_bounds(struct state *state, /* BOLT #2: * - * It MUST fail the channel if `max-accepted-htlcs` is greater + * It MUST fail the channel if `max_accepted_htlcs` is greater * than 483. */ if (remoteconf->max_accepted_htlcs > 483) @@ -155,7 +155,7 @@ static void set_reserve(u64 *reserve, u64 funding) /* BOLT #2: * - * A sending node MUST ensure `temporary-channel-id` is unique from any other + * A sending node MUST ensure `temporary_channel_id` is unique from any other * channel id with the same peer. */ static void temporary_channel_id(struct channel_id *channel_id) @@ -230,15 +230,15 @@ static u8 *funder_channel(struct state *state, /* BOLT #2: * - * The sender MUST set `funding-satoshis` to less than 2^24 satoshi. */ + * The sender MUST set `funding_satoshis` to less than 2^24 satoshi. */ if (state->funding_satoshis >= 1 << 24) peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_BAD_PARAM, "funding_satoshis must be < 2^24"); /* BOLT #2: * - * The sender MUST set `push-msat` to equal or less than to 1000 * - * `funding-satoshis`. + * The sender MUST set `push_msat` to equal or less than to 1000 * + * `funding_satoshis`. */ if (state->push_msat > 1000 * state->funding_satoshis) peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_BAD_PARAM, @@ -272,9 +272,9 @@ static u8 *funder_channel(struct state *state, /* BOLT #2: * - * The receiver MUST fail the channel if `funding-pubkey`, - * `revocation-basepoint`, `payment-basepoint` or - * `delayed-payment-basepoint` are not valid DER-encoded compressed + * The receiver MUST fail the channel if `funding_pubkey`, + * `revocation_basepoint`, `payment_basepoint` or + * `delayed_payment_basepoint` are not valid DER-encoded compressed * secp256k1 pubkeys. */ if (!fromwire_accept_channel(msg, NULL, &id_in, @@ -297,8 +297,8 @@ static u8 *funder_channel(struct state *state, /* BOLT #2: * - * The `temporary-channel-id` MUST be the same as the - * `temporary-channel-id` in the `open_channel` message. */ + * The `temporary_channel_id` MUST be the same as the + * `temporary_channel_id` in the `open_channel` message. */ if (!structeq(&id_in, &channel_id)) peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_PEER_READ_FAILED, "accept_channel ids don't match: sent %s got %s", @@ -307,7 +307,7 @@ static u8 *funder_channel(struct state *state, /* BOLT #2: * - * The receiver MAY reject the `minimum-depth` if it considers it + * The receiver MAY reject the `minimum_depth` if it considers it * unreasonably large. * * Other fields have the same requirements as their counterparts in @@ -398,10 +398,10 @@ static u8 *funder_channel(struct state *state, /* BOLT #2: * - * This message introduces the `channel-id` to identify the channel, which + * This message introduces the `channel_id` to identify the channel, which * is derived from the funding transaction by combining the - * `funding-txid` and the `funding-output-index` using big-endian - * exclusive-OR (ie. `funding-output-index` alters the last two + * `funding_txid` and the `funding_output_index` using big-endian + * exclusive-OR (ie. `funding_output_index` alters the last two * bytes). */ derive_channel_id(&channel_id, @@ -472,9 +472,9 @@ static u8 *fundee_channel(struct state *state, /* BOLT #2: * - * The receiver MUST fail the channel if `funding-pubkey`, - * `revocation-basepoint`, `payment-basepoint` or - * `delayed-payment-basepoint` are not valid DER-encoded compressed + * The receiver MUST fail the channel if `funding_pubkey`, + * `revocation_basepoint`, `payment_basepoint` or + * `delayed_payment_basepoint` are not valid DER-encoded compressed * secp256k1 pubkeys. */ if (!fromwire_open_channel(peer_msg, NULL, &chain_hash.sha, &channel_id, @@ -497,7 +497,7 @@ static u8 *fundee_channel(struct state *state, /* BOLT #2: * - * The receiving MUST reject the channel if the `chain-hash` value + * The receiving MUST reject the channel if the `chain_hash` value * within the `open_channel` message is set to a hash of a chain * unknown to the receiver. */ @@ -520,8 +520,8 @@ static u8 *fundee_channel(struct state *state, /* BOLT #2: * - * The receiving node ... MUST fail the channel if `push-msat` is - * greater than `funding-amount` * 1000. + * The receiving node ... MUST fail the channel if `push_msat` is + * greater than `funding_satoshis` * 1000. */ if (state->push_msat > state->funding_satoshis * 1000) peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_PEER_BAD_FUNDING, @@ -531,7 +531,7 @@ static u8 *fundee_channel(struct state *state, /* BOLT #2: * - * The receiver MUST fail the channel if it considers `feerate-per-kw` + * The receiver MUST fail the channel if it considers `feerate_per_kw` * too small for timely processing, or unreasonably large. */ if (state->feerate_per_kw < min_feerate) @@ -581,8 +581,8 @@ static u8 *fundee_channel(struct state *state, /* BOLT #2: * - * The sender MUST set `temporary-channel-id` the same as the - * `temporary-channel-id` in the `open_channel` message. */ + * The sender MUST set `temporary_channel_id` the same as the + * `temporary_channel_id` in the `open_channel` message. */ if (!structeq(&id_in, &channel_id)) peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_PEER_READ_FAILED, "funding_created ids don't match: sent %s got %s", @@ -625,10 +625,10 @@ static u8 *fundee_channel(struct state *state, /* BOLT #2: * - * This message introduces the `channel-id` to identify the channel, + * This message introduces the `channel_id` to identify the channel, * which is derived from the funding transaction by combining the - * `funding-txid` and the `funding-output-index` using big-endian - * exclusive-OR (ie. `funding-output-index` alters the last two + * `funding_txid` and the `funding_output_index` using big-endian + * exclusive-OR (ie. `funding_output_index` alters the last two * bytes). */ derive_channel_id(&channel_id, diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index c7abafc62..c483391a5 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -875,11 +875,11 @@ static u8 *make_failmsg(const tal_t *ctx, const struct htlc_end *hend, * processing an incoming Sphinx packet along with the HTLC message it's * encapsulated within, if the following inequality doesn't hold, then the * HTLC should be rejected as it indicates a prior node in the path has - * deviated from the specified paramters: + * deviated from the specified parameters: * * incoming_htlc_amt - fee >= amt_to_forward * - * Where `fee` is calculated according to the receving node's advertised fee + * Where `fee` is calculated according to the receiving node's advertised fee * schema as described in [BOLT 7](https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#htlc-fees), or 0 if this node is the * final hop. */ @@ -899,15 +899,15 @@ static bool check_amount(struct htlc_end *hend, * * `outgoing_cltv_value` - The CLTV value that the _outgoing_ HTLC carrying * the packet should have. * - * cltv-expiry - cltv-expiry-delta = outgoing_cltv_value + * cltv_expiry - cltv_expiry_delta = outgoing_cltv_value * * Inclusion of this field allows a node to both authenticate the information - * specified by the original sender and the paramaters of the HTLC forwarded, - * and ensure the original sender is using the current `cltv-expiry-delta` value. - * If there is no next hop, `cltv-expiry-delta` is zero. + * specified by the original sender and the parameters of the HTLC forwarded, + * and ensure the original sender is using the current `cltv_expiry_delta` value. + * If there is no next hop, `cltv_expiry_delta` is zero. * If the values don't correspond, then the HTLC should be failed+rejected as * this indicates the incoming node has tampered with the intended HTLC - * values, or the origin has an obsolete `cltv-expiry-delta` value. + * values, or the origin has an obsolete `cltv_expiry_delta` value. * The node MUST be consistent in responding to an unexpected * `outgoing_cltv_value` whether it is the final hop or not, to avoid * leaking that information. @@ -948,12 +948,12 @@ static void handle_localpay(struct htlc_end *hend, /* BOLT #4: * - * If the `amt_to_forward` does not match the `incoming_htlc_amt` of + * If the `amt_to_forward` is higher than `incoming_htlc_amt` of * the HTLC at the final hop: * * 1. type: 19 (`final_incorrect_htlc_amount`) * 2. data: - * * [4:incoming-htlc-amt] + * * [`4`:`incoming_htlc_amt`] */ if (!check_amount(hend, amt_to_forward, hend->msatoshis, 0)) { err = towire_final_incorrect_htlc_amount(hend, hend->msatoshis); @@ -962,12 +962,12 @@ static void handle_localpay(struct htlc_end *hend, /* BOLT #4: * - * If the `outgoing_cltv_value` does not match the `ctlv-expiry` of + * If the `outgoing_cltv_value` does not match the `ctlv_expiry` of * the HTLC at the final hop: * * 1. type: 18 (`final_incorrect_cltv_expiry`) * 2. data: - * * [4:cltv-expiry] + * * [`4`:`cltv_expiry`] */ if (!check_ctlv(hend, cltv_expiry, outgoing_cltv_value, 0)) { err = towire_final_incorrect_cltv_expiry(hend, cltv_expiry); @@ -1000,7 +1000,7 @@ static void handle_localpay(struct htlc_end *hend, /* BOLT #4: * - * If the `cltv-expiry` is too low, the final node MUST fail the HTLC: + * If the `cltv_expiry` is too low, the final node MUST fail the HTLC: */ if (get_block_height(hend->peer->ld->topology) + hend->peer->ld->dstate.config.deadline_blocks >= cltv_expiry) { @@ -1110,7 +1110,7 @@ static void forward_htlc(struct htlc_end *hend, * The node creating `channel_update` SHOULD accept HTLCs which pay a * fee equal or greater than: * - * fee-base-msat + htlc-amount-msat * fee-proportional-millionths / 1000000 + * fee_base_msat + amount_msat * fee_proportional_millionths / 1000000 */ if (mul_overflows_u64(amt_to_forward, ld->dstate.config.fee_per_satoshi)) { @@ -1139,8 +1139,8 @@ static void forward_htlc(struct htlc_end *hend, * setting for the outgoing channel: * 1. type: UPDATE|14 (`expiry_too_soon`) * 2. data: - * * [2:len] - * * [len:channel_update] + * * [`2`:`len`] + * * [`len`:`channel_update`] */ if (get_block_height(next->ld->topology) + next->ld->dstate.config.deadline_blocks >= outgoing_cltv_value) { @@ -1739,7 +1739,7 @@ static void channel_config(struct lightningd *ld, /* BOLT #2: * - * The sender SHOULD set `dust-limit-satoshis` to a sufficient + * The sender SHOULD set `dust_limit_satoshis` to a sufficient * value to allow commitment transactions to propagate through * the Bitcoin network. */ @@ -1751,7 +1751,7 @@ static void channel_config(struct lightningd *ld, /* BOLT #2: * - * The sender SHOULD set `to-self-delay` sufficient to ensure + * The sender SHOULD set `to_self_delay` sufficient to ensure * the sender can irreversibly spend a commitment transaction * output in case of misbehavior by the receiver. */ @@ -1759,7 +1759,7 @@ static void channel_config(struct lightningd *ld, /* BOLT #2: * - * It MUST fail the channel if `max-accepted-htlcs` is greater than + * It MUST fail the channel if `max_accepted_htlcs` is greater than * 483. */ ours->max_accepted_htlcs = 483; @@ -1803,8 +1803,9 @@ void peer_fundee_open(struct peer *peer, const u8 *from_peer) /* BOLT #2: * - * The sender SHOULD set `minimum-depth` to an amount where - * the sender considers reorganizations to be low risk. + * The sender SHOULD set `minimum_depth` to a number of blocks it + * considers reasonable to avoid double-spending of the funding + * transaction. */ peer->minimum_depth = ld->dstate.config.anchor_confirms; diff --git a/lightningd/peer_failed.c b/lightningd/peer_failed.c index e1f343f7b..16c566279 100644 --- a/lightningd/peer_failed.c +++ b/lightningd/peer_failed.c @@ -19,7 +19,7 @@ void peer_failed(int peer_fd, struct crypto_state *cs, /* BOLT #1: * - * The channel is referred to by `channel-id` unless `channel-id` is + * The channel is referred to by `channel_id` unless `channel_id` is * zero (ie. all bytes zero), in which case it refers to all channels. */ if (!channel_id) { diff --git a/lightningd/sphinx.h b/lightningd/sphinx.h index 0b2b8ef17..d4bb333fc 100644 --- a/lightningd/sphinx.h +++ b/lightningd/sphinx.h @@ -35,22 +35,34 @@ enum route_next_case { /* BOLT #4: * - * The hops_data field is a structure that holds obfuscated versions of the next hop's address, transfer information and the associated HMAC. It is 1060 bytes long, and has the following structure: - -``` -+-----------+-------------+----------+-----------+-------------+----------+-----------+ -| n_1 realm | n_1 per-hop | n_1 HMAC | n_2 realm | n_2 per-hop | n_2 HMAC | ...filler | -+-----------+-------------+----------+----------+--------------+----------+------------+ -``` - -The realm byte determines the format of the per-hop; so far only realm 0 is defined, and for that, the per-hop format is: - -``` -+----------------------+--------------------------+-------------------------------+--------------------+ -| channel_id (8 bytes) | amt_to_forward (4 bytes) | outgoing_cltv_value (4 bytes) | padding (16 bytes) | -+----------------------+--------------------------+-------------------------------+--------------------+ -``` -*/ + * The `hops_data` field is a structure that holds obfuscated versions of the + * next hop's address, transfer information and the associated HMAC. It is + * 1300 bytes long, and has the following structure: + * + * 1. type: `hops_data` + * 2. data: + * * [`1`:`realm`] + * * [`32`:`per_hop`] + * * [`32`:`HMAC`] + * * ... + * * `filler` + * + * Where the `realm`, `HMAC` and `per_hop` (whose contents depend on `realm`) + * are repeated for each hop, and `filler` consists of obfuscated + * deterministically generated padding. For details about how the `filler` is + * generated please see below. In addition, `hops_data` is incrementally + * obfuscated at each hop. + * + * The `realm` byte determines the format of the `per_hop`; so far only + * `realm` 0 is defined, and for that, the `per_hop` format is: + * + * 1. type: `per_hop` (for `realm` 0) + * 2. data: + * * [`8`:`channel_id`] + * * [`4`:`amt_to_forward`] + * * [`4`:`outgoing_cltv_value`] + * * [`16`:`padding`] + */ struct hop_data { u8 realm; struct short_channel_id channel_id; diff --git a/lightningd/test/run-channel.c b/lightningd/test/run-channel.c index 176cddc7e..e7e2f83e6 100644 --- a/lightningd/test/run-channel.c +++ b/lightningd/test/run-channel.c @@ -479,7 +479,7 @@ int main(void) /* BOLT #3: * - * name: commitment tx with all 5 htlcs untrimmed (minimum feerate) + * name: commitment tx with all 5 HTLCs untrimmed (minimum feerate) * to_local_msat: 6988000000 * to_remote_msat: 3000000000 * local_feerate_per_kw: 0 diff --git a/lightningd/test/run-commit_tx.c b/lightningd/test/run-commit_tx.c index b7a8960db..1538c95ac 100644 --- a/lightningd/test/run-commit_tx.c +++ b/lightningd/test/run-commit_tx.c @@ -716,7 +716,7 @@ int main(void) /* BOLT #3: * - * name: commitment tx with all 5 htlcs untrimmed (minimum feerate) + * name: commitment tx with all 5 HTLCs untrimmed (minimum feerate) * to_local_msat: 6988000000 * to_remote_msat: 3000000000 * local_feerate_per_kw: 0 diff --git a/wire/fromwire.c b/wire/fromwire.c index e4666c38a..7cb9c9f32 100644 --- a/wire/fromwire.c +++ b/wire/fromwire.c @@ -209,10 +209,10 @@ REGISTER_TYPE_TO_HEXSTR(channel_id); /* BOLT #2: * - * This message introduces the `channel-id` to identify the channel, which is - * derived from the funding transaction by combining the `funding-txid` and - * the `funding-output-index` using big-endian exclusive-OR - * (ie. `funding-output-index` alters the last two bytes). + * This message introduces the `channel_id` to identify the channel, which is + * derived from the funding transaction by combining the `funding_txid` and + * the `funding_output_index` using big-endian exclusive-OR + * (ie. `funding_output_index` alters the last two bytes). */ void derive_channel_id(struct channel_id *channel_id, struct sha256_double *txid, u16 txout)