mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 15:44:21 +01:00
daemon: disable old BOLT checks.
This is useful for the next patch. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
uint64_t fee_by_feerate(size_t txsize, uint64_t fee_rate)
|
||||
{
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The fee for a transaction MUST be calculated by multiplying this
|
||||
* bytecount by the fee rate, dividing by 1000 and truncating
|
||||
@@ -21,7 +21,7 @@ uint64_t fee_by_feerate(size_t txsize, uint64_t fee_rate)
|
||||
return txsize * fee_rate / 2000 * 2;
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST use the formula 338 + 32 bytes for every non-dust HTLC
|
||||
* as the bytecount for calculating commitment transaction fees. Note
|
||||
@@ -55,7 +55,7 @@ static uint64_t pay_fee(struct channel_oneside *side, uint64_t fee_msat)
|
||||
}
|
||||
}
|
||||
|
||||
/* Charge the fee as per BOLT #2 */
|
||||
/* Charge the fee as per FIXME-OLD #2 */
|
||||
static void recalculate_fees(struct channel_oneside *a,
|
||||
struct channel_oneside *b,
|
||||
uint64_t fee_msat)
|
||||
@@ -67,7 +67,7 @@ static void recalculate_fees(struct channel_oneside *a,
|
||||
b->pay_msat += b->fee_msat;
|
||||
a->fee_msat = b->fee_msat = 0;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* 1. If each nodes can afford half the fee from their
|
||||
* to-`final_key` output, reduce the two to-`final_key`
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#define MAX_PKT_LEN (1024 * 1024)
|
||||
|
||||
/* BOLT#1:
|
||||
/* FIXME-OLD#1:
|
||||
`length` is a 4-byte little-endian field indicating the size of the unencrypted body.
|
||||
*/
|
||||
|
||||
@@ -70,7 +70,7 @@ struct enckey {
|
||||
};
|
||||
|
||||
|
||||
/* BOLT #1:
|
||||
/* FIXME-OLD #1:
|
||||
* * sending-key: SHA256(shared-secret || sending-node-session-pubkey)
|
||||
* * receiving-key: SHA256(shared-secret || receiving-node-session-pubkey)
|
||||
*/
|
||||
@@ -100,7 +100,7 @@ struct dir_state {
|
||||
static void setup_crypto(struct dir_state *dir,
|
||||
u8 shared_secret[32], u8 serial_pubkey[33])
|
||||
{
|
||||
/* BOLT #1: Nonces...MUST begin at 0 */
|
||||
/* FIXME-OLD #1: Nonces...MUST begin at 0 */
|
||||
dir->nonce = 0;
|
||||
|
||||
dir->enckey = enckey_from_secret(shared_secret, serial_pubkey);
|
||||
@@ -134,7 +134,7 @@ static void proto_tal_free(void *allocator_data, void *pointer)
|
||||
|
||||
static void le64_nonce(unsigned char *npub, u64 nonce)
|
||||
{
|
||||
/* BOLT #1: Nonces are 64-bit little-endian numbers */
|
||||
/* FIXME-OLD #1: Nonces are 64-bit little-endian numbers */
|
||||
le64 le_nonce = cpu_to_le64(nonce);
|
||||
memcpy(npub, &le_nonce, sizeof(le_nonce));
|
||||
BUILD_ASSERT(crypto_aead_chacha20poly1305_NPUBBYTES == sizeof(le_nonce));
|
||||
@@ -278,7 +278,7 @@ static bool decrypt_header(struct log *log, struct io_data *iod,
|
||||
log_debug(log, "Decrypted header len %u",
|
||||
le32_to_cpu(iod->hdr_in.length));
|
||||
|
||||
/* BOLT #1: `length` MUST NOT exceed 1MB (1048576 bytes). */
|
||||
/* FIXME-OLD #1: `length` MUST NOT exceed 1MB (1048576 bytes). */
|
||||
if (le32_to_cpu(iod->hdr_in.length) > MAX_PKT_LEN) {
|
||||
log_unusual(log,
|
||||
"Packet overlength: %"PRIu64,
|
||||
@@ -381,7 +381,7 @@ static bool check_proof(struct key_negotiate *neg, struct log *log,
|
||||
if (!auth)
|
||||
return false;
|
||||
|
||||
/* BOLT #1:
|
||||
/* FIXME-OLD #1:
|
||||
*
|
||||
* The receiving node MUST check that:
|
||||
*
|
||||
@@ -397,7 +397,7 @@ static bool check_proof(struct key_negotiate *neg, struct log *log,
|
||||
return false;
|
||||
}
|
||||
|
||||
/* BOLT #1:
|
||||
/* FIXME-OLD #1:
|
||||
*
|
||||
* 2. `session_sig` is a valid secp256k1 ECDSA signature encoded as
|
||||
* a 32-byte big endian R value, followed by a 32-byte big
|
||||
@@ -409,7 +409,7 @@ static bool check_proof(struct key_negotiate *neg, struct log *log,
|
||||
}
|
||||
|
||||
|
||||
/* BOLT #1:
|
||||
/* FIXME-OLD #1:
|
||||
*
|
||||
* 3. `session_sig` is the signature of the SHA256 of SHA256 of the
|
||||
* its own sessionpubkey, using the secret key corresponding to
|
||||
@@ -519,7 +519,7 @@ static struct io_plan *keys_exchanged(struct io_conn *conn,
|
||||
setup_crypto(&neg->iod->in, shared_secret, neg->their_sessionpubkey);
|
||||
setup_crypto(&neg->iod->out, shared_secret, neg->our_sessionpubkey);
|
||||
|
||||
/* BOLT #1:
|
||||
/* FIXME-OLD #1:
|
||||
*
|
||||
* `session_sig` is the signature of the SHA256 of SHA256 of the its
|
||||
* own sessionpubkey, using the secret key corresponding to the
|
||||
@@ -540,7 +540,7 @@ static struct io_plan *discard_extra(struct io_conn *conn,
|
||||
{
|
||||
size_t len = le32_to_cpu(neg->keylen);
|
||||
|
||||
/* BOLT#1: Additional fields MAY be added, and MUST be
|
||||
/* FIXME-OLD#1: Additional fields MAY be added, and MUST be
|
||||
* included in the `length` field. These MUST be ignored by
|
||||
* implementations which do not understand them. */
|
||||
if (len > sizeof(neg->their_sessionpubkey)) {
|
||||
@@ -560,7 +560,7 @@ static struct io_plan *discard_extra(struct io_conn *conn,
|
||||
static struct io_plan *session_key_receive(struct io_conn *conn,
|
||||
struct key_negotiate *neg)
|
||||
{
|
||||
/* BOLT#1: The `length` field is the length after the field
|
||||
/* FIXME-OLD#1: The `length` field is the length after the field
|
||||
itself, and MUST be 33 or greater. */
|
||||
if (le32_to_cpu(neg->keylen) < sizeof(neg->their_sessionpubkey)) {
|
||||
log_unusual(neg->log, "short session key length %u",
|
||||
@@ -568,7 +568,7 @@ static struct io_plan *session_key_receive(struct io_conn *conn,
|
||||
return io_close(conn);
|
||||
}
|
||||
|
||||
/* BOLT#1: `length` MUST NOT exceed 1MB (1048576 bytes). */
|
||||
/* FIXME-OLD#1: `length` MUST NOT exceed 1MB (1048576 bytes). */
|
||||
if (le32_to_cpu(neg->keylen) > 1048576) {
|
||||
log_unusual(neg->log,
|
||||
"Oversize session key length %u",
|
||||
@@ -623,7 +623,7 @@ struct io_plan *peer_crypto_setup_(struct io_conn *conn,
|
||||
secp256k1_pubkey sessionkey;
|
||||
struct key_negotiate *neg;
|
||||
|
||||
/* BOLT #1:
|
||||
/* FIXME-OLD #1:
|
||||
*
|
||||
* The 4-byte length for each message is encrypted separately
|
||||
* (resulting in a 20 byte header when the authentication tag
|
||||
|
||||
@@ -225,7 +225,7 @@ static const struct config testnet_config = {
|
||||
.anchor_confirms_max = 10,
|
||||
|
||||
/* At some point, you've got to let it go... */
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* Outputs... are considered *irrevocably resolved* once they
|
||||
* are included in a block at least 100 deep on the most-work
|
||||
@@ -292,7 +292,7 @@ static const struct config mainnet_config = {
|
||||
.anchor_confirms_max = 10,
|
||||
|
||||
/* At some point, you've got to let it go... */
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* Outputs... are considered *irrevocably resolved* once they
|
||||
* are included in a block at least 100 deep on the most-work
|
||||
@@ -359,7 +359,7 @@ static void check_config(struct lightningd_state *dstate)
|
||||
if (dstate->config.anchor_confirms == 0)
|
||||
fatal("anchor-confirms must be greater than zero");
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* a node MUST estimate the deadline for successful redemption
|
||||
* for each HTLC it offers. A node MUST NOT offer a HTLC
|
||||
|
||||
@@ -245,7 +245,7 @@ Pkt *pkt_init(struct peer *peer, u64 ack)
|
||||
Init *i = tal(peer, Init);
|
||||
init__init(i);
|
||||
i->ack = ack;
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node SHOULD set the `features` field of the `init`
|
||||
* message to a bitset representing features it supports.
|
||||
@@ -394,7 +394,7 @@ Pkt *accept_pkt_htlc_add(struct peer *peer, const Pkt *pkt, struct htlc **h)
|
||||
struct sha256 rhash;
|
||||
struct abs_locktime expiry;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* `amount_msat` MUST BE greater than 0.
|
||||
*/
|
||||
@@ -408,7 +408,7 @@ Pkt *accept_pkt_htlc_add(struct peer *peer, const Pkt *pkt, struct htlc **h)
|
||||
if (abs_locktime_is_seconds(&expiry))
|
||||
return pkt_err(peer, "HTLC expiry in seconds not supported!");
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT add a HTLC if it would result in it
|
||||
* offering more than 300 HTLCs in the remote commitment transaction.
|
||||
@@ -416,7 +416,7 @@ Pkt *accept_pkt_htlc_add(struct peer *peer, const Pkt *pkt, struct htlc **h)
|
||||
if (peer->remote.staging_cstate->side[REMOTE].num_htlcs == 300)
|
||||
return pkt_err(peer, "Too many HTLCs");
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST set `id` to a unique identifier for this HTLC
|
||||
* amongst all past or future `update_add_htlc` messages.
|
||||
@@ -427,7 +427,7 @@ Pkt *accept_pkt_htlc_add(struct peer *peer, const Pkt *pkt, struct htlc **h)
|
||||
if (htlc_get(&peer->htlcs, u->id, REMOTE))
|
||||
return pkt_err(peer, "HTLC id %"PRIu64" clashes for you", u->id);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* ...and the receiving node MUST add the HTLC addition to the
|
||||
* unacked changeset for its local commitment. */
|
||||
@@ -443,7 +443,7 @@ static Pkt *find_commited_htlc(struct peer *peer, uint64_t id,
|
||||
{
|
||||
*local_htlc = htlc_get(&peer->htlcs, id, LOCAL);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST check that `id` corresponds to an HTLC in its
|
||||
* current commitment transaction, and MUST fail the
|
||||
@@ -534,7 +534,7 @@ Pkt *accept_pkt_revocation(struct peer *peer, const Pkt *pkt)
|
||||
assert(peer->their_prev_revocation_hash);
|
||||
proto_to_sha256(r->revocation_preimage, &preimage);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The receiver of `update_revocation` MUST check that the
|
||||
* SHA256 hash of `revocation_preimage` matches the previous commitment
|
||||
@@ -571,7 +571,7 @@ Pkt *accept_pkt_close_shutdown(struct peer *peer, const Pkt *pkt)
|
||||
{
|
||||
const CloseShutdown *c = pkt->close_shutdown;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* 1. `OP_DUP` `OP_HASH160` `20` 20-bytes `OP_EQUALVERIFY` `OP_CHECKSIG`
|
||||
* (pay to pubkey hash), OR
|
||||
|
||||
130
daemon/peer.c
130
daemon/peer.c
@@ -388,7 +388,7 @@ static bool committed_to_htlcs(const struct peer *peer)
|
||||
|
||||
static void peer_calculate_close_fee(struct peer *peer)
|
||||
{
|
||||
/* Use actual worst-case length of close tx: based on BOLT#02's
|
||||
/* Use actual worst-case length of close tx: based on FIXME-OLD#02's
|
||||
* commitment tx numbers, but only 1 byte for output count */
|
||||
const uint64_t txsize = 41 + 221 + 10 + 32 + 32;
|
||||
uint64_t maxfee;
|
||||
@@ -396,7 +396,7 @@ static void peer_calculate_close_fee(struct peer *peer)
|
||||
peer->closing.our_fee
|
||||
= fee_by_feerate(txsize, get_feerate(peer->dstate));
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
* The sender MUST set `close_fee` lower than or equal to the
|
||||
* fee of the final commitment transaction, and MUST set
|
||||
* `close_fee` to an even number of satoshis.
|
||||
@@ -479,7 +479,7 @@ static bool peer_received_unexpected_pkt(struct peer *peer, const Pkt *pkt,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST fail the connection if it receives an `err`
|
||||
* message, and MUST NOT send an `err` message in this case.
|
||||
@@ -1171,7 +1171,7 @@ static const char *changestates(struct peer *peer,
|
||||
changed = true;
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT send an `update_commit` message which does
|
||||
* not include any updates.
|
||||
@@ -1196,7 +1196,7 @@ static bool closing_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||
log_info(peer->log, "closing_pkt_in: they offered close fee %"PRIu64,
|
||||
c->close_fee);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The sender MUST set `close_fee` lower than or equal to the fee of the
|
||||
* final commitment transaction, and MUST set `close_fee` to an even
|
||||
@@ -1210,7 +1210,7 @@ static bool closing_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||
|
||||
/* FIXME: Don't accept tiny fee at all? */
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
... otherwise it SHOULD propose a
|
||||
value strictly between the received `close_fee` and its
|
||||
previously-sent `close_fee`.
|
||||
@@ -1228,7 +1228,7 @@ static bool closing_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||
}
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The receiver MUST check `sig` is valid for the close
|
||||
* transaction with the given `close_fee`, and MUST fail the
|
||||
@@ -1256,7 +1256,7 @@ static bool closing_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||
return peer_database_err(peer);
|
||||
|
||||
if (peer->closing.our_fee != peer->closing.their_fee) {
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* If the receiver agrees with the fee, it SHOULD reply with a
|
||||
* `close_signature` with the same `close_fee` value,
|
||||
@@ -1291,7 +1291,7 @@ static bool closing_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||
if (peer->closing.our_fee == peer->closing.their_fee) {
|
||||
const struct bitcoin_tx *close;
|
||||
log_info(peer->log, "accept_pkt_close_sig: we agree");
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* Once a node has sent or received a `close_signature` with
|
||||
* matching `close_fee` it SHOULD close the connection and
|
||||
@@ -1340,7 +1340,7 @@ static Pkt *handle_pkt_commit(struct peer *peer, const Pkt *pkt)
|
||||
|
||||
db_start_transaction(peer);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT send an `update_commit` message which does
|
||||
* not include any updates.
|
||||
@@ -1357,7 +1357,7 @@ static Pkt *handle_pkt_commit(struct peer *peer, const Pkt *pkt)
|
||||
/* Create new commit info for this commit tx. */
|
||||
ci->revocation_hash = peer->local.next_revocation_hash;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A receiving node MUST apply all local acked and unacked
|
||||
* changes except unacked fee changes to the local commitment
|
||||
@@ -1372,7 +1372,7 @@ static Pkt *handle_pkt_commit(struct peer *peer, const Pkt *pkt)
|
||||
log_add_struct(peer->log, " for %s", struct channel_state, ci->cstate);
|
||||
log_add_struct(peer->log, " (txid %s)", struct sha256_double, &ci->txid);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* If the commitment transaction has only a single output which pays
|
||||
* to the other node, `sig` MUST be unset. Otherwise, a sending node
|
||||
@@ -1386,7 +1386,7 @@ static Pkt *handle_pkt_commit(struct peer *peer, const Pkt *pkt)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A receiving node MUST apply all local acked and unacked changes
|
||||
* except unacked fee changes to the local commitment, then it MUST
|
||||
@@ -1457,7 +1457,7 @@ static Pkt *handle_pkt_htlc_add(struct peer *peer, const Pkt *pkt)
|
||||
return err;
|
||||
assert(htlc->state == RCVD_ADD_HTLC);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT offer `amount_msat` it cannot pay for in
|
||||
* the remote commitment transaction at the current `fee_rate` (see
|
||||
@@ -1503,7 +1503,7 @@ static Pkt *handle_pkt_htlc_fail(struct peer *peer, const Pkt *pkt)
|
||||
|
||||
cstate_fail_htlc(peer->local.staging_cstate, htlc);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* ... and the receiving node MUST add the HTLC fulfill/fail
|
||||
* to the unacked changeset for its local commitment.
|
||||
@@ -1533,7 +1533,7 @@ static Pkt *handle_pkt_htlc_fulfill(struct peer *peer, const Pkt *pkt)
|
||||
return pkt_err(peer, "database error");
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* ... and the receiving node MUST add the HTLC fulfill/fail
|
||||
* to the unacked changeset for its local commitment.
|
||||
@@ -1567,7 +1567,7 @@ static Pkt *handle_pkt_feechange(struct peer *peer, const Pkt *pkt)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The sending node MUST NOT send a `fee_rate` which it could not
|
||||
* afford (see "Fee Calculation), were it applied to the receiving
|
||||
@@ -1602,7 +1602,7 @@ static Pkt *handle_pkt_revocation(struct peer *peer, const Pkt *pkt,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The receiver of `update_revocation`... MUST add the remote
|
||||
* unacked changes to the set of local acked changes.
|
||||
@@ -1651,7 +1651,7 @@ static bool shutdown_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||
break;
|
||||
|
||||
case PKT__PKT_UPDATE_ADD_HTLC:
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT send a `update_add_htlc` after a
|
||||
* `close_shutdown` */
|
||||
@@ -1662,7 +1662,7 @@ static bool shutdown_pkt_in(struct peer *peer, const Pkt *pkt)
|
||||
break;
|
||||
|
||||
case PKT__PKT_CLOSE_SHUTDOWN:
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node... MUST NOT send more than one `close_shutdown`. */
|
||||
if (peer->closing.their_script)
|
||||
@@ -1761,7 +1761,7 @@ static bool do_commit(struct peer *peer, struct command *jsoncmd)
|
||||
|
||||
/* Create new commit info for this commit tx. */
|
||||
ci->revocation_hash = peer->remote.next_revocation_hash;
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* ...a sending node MUST apply all remote acked and unacked
|
||||
* changes except unacked fee changes to the remote commitment
|
||||
@@ -1832,7 +1832,7 @@ static bool peer_start_shutdown(struct peer *peer)
|
||||
peer->closing.our_script = scriptpubkey_p2sh(peer, redeemscript);
|
||||
tal_free(redeemscript);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node SHOULD send a `close_shutdown` (if it has
|
||||
* not already) after receiving `close_shutdown`.
|
||||
@@ -2018,7 +2018,7 @@ static bool command_htlc_fail(struct peer *peer, struct htlc *htlc)
|
||||
if (!state_can_remove_htlc(peer->state))
|
||||
return false;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The sending node MUST add the HTLC fulfill/fail to the
|
||||
* unacked changeset for its remote commitment
|
||||
@@ -2033,7 +2033,7 @@ static bool command_htlc_fail(struct peer *peer, struct htlc *htlc)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* If the node receives... a redemption preimage for an unresolved *commitment
|
||||
* tx* output it was offered, it MUST *resolve* the output by spending it using
|
||||
@@ -2067,7 +2067,7 @@ static bool command_htlc_fulfill(struct peer *peer, struct htlc *htlc)
|
||||
if (!state_can_remove_htlc(peer->state))
|
||||
return false;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The sending node MUST add the HTLC fulfill/fail to the
|
||||
* unacked changeset for its remote commitment
|
||||
@@ -2112,7 +2112,7 @@ const char *command_htlc_add(struct peer *peer, u64 msatoshi,
|
||||
return "expiry too far";
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT add a HTLC if it would result in it
|
||||
* offering more than 300 HTLCs in the remote commitment transaction.
|
||||
@@ -2134,13 +2134,13 @@ const char *command_htlc_add(struct peer *peer, u64 msatoshi,
|
||||
msatoshi, rhash, expiry, route, tal_count(route),
|
||||
src, SENT_ADD_HTLC);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The sending node MUST add the HTLC addition to the unacked
|
||||
* changeset for its remote commitment
|
||||
*/
|
||||
if (!cstate_add_htlc(peer->remote.staging_cstate, *htlc, true)) {
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT offer `amount_msat` it cannot pay for in
|
||||
* the remote commitment transaction at the current `fee_rate`
|
||||
@@ -2248,7 +2248,7 @@ static void retransmit_updates(struct peer *peer)
|
||||
struct htlc_map_iter it;
|
||||
struct htlc *h;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MAY simply retransmit messages which are identical to the
|
||||
* previous transmission. */
|
||||
@@ -2277,7 +2277,7 @@ static void retransmit_updates(struct peer *peer)
|
||||
assert(!peer->feechanges[SENT_FEECHANGE]);
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* On disconnection, a node MUST reverse any uncommitted changes sent by the
|
||||
* other side (ie. `update_add_htlc`, `update_fee`, `update_fail_htlc` and
|
||||
@@ -2382,7 +2382,7 @@ static void retransmit_pkts(struct peer *peer, s64 ack)
|
||||
ack, peer->remote.commit ? peer->remote.commit->order : -2,
|
||||
peer->local.commit ? peer->local.commit->order : -2);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MAY assume that only one of each type of message need be
|
||||
* retransmitted. A node SHOULD retransmit the last of each message
|
||||
@@ -2395,7 +2395,7 @@ static void retransmit_pkts(struct peer *peer, s64 ack)
|
||||
queue_pkt_open_commit_sig(peer);
|
||||
} else if (peer->remote.commit
|
||||
&& ack == peer->remote.commit->order) {
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* Before retransmitting `update_commit`, the node
|
||||
* MUST send appropriate `update_add_htlc`,
|
||||
@@ -2491,7 +2491,7 @@ static struct io_plan *init_pkt_in(struct io_conn *conn, struct peer *peer)
|
||||
if (peer->inpkt->init->has_features) {
|
||||
size_t i;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* The receiving node SHOULD ignore any odd feature bits it
|
||||
* does not support, and MUST fail the connection if any
|
||||
@@ -2576,7 +2576,7 @@ static struct io_plan *peer_send_init(struct io_conn *conn, struct peer *peer)
|
||||
PRIu64" revokes + %"PRIu64" shutdown + %"PRIu64" closing",
|
||||
open, sigs, revokes, shutdown, closing);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST send an `init` message immediately immediately after
|
||||
* it has validated the `authenticate` message. A node MUST set
|
||||
@@ -2993,7 +2993,7 @@ static struct io_plan *crypto_on_in(struct io_conn *conn,
|
||||
{
|
||||
struct peer *peer;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST handle continuing a previous channel on a new encrypted
|
||||
* transport. */
|
||||
@@ -3289,7 +3289,7 @@ static void check_htlc_expiry(struct peer *peer)
|
||||
}
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT offer a HTLC after this deadline, and MUST
|
||||
* fail the connection if an HTLC which it offered is in
|
||||
@@ -3368,7 +3368,7 @@ static enum watch_result anchor_depthchange(struct peer *peer,
|
||||
remote_changes_pending(peer);
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST update bitcoin fees if it estimates that the
|
||||
* current commitment transaction will not be processed in a
|
||||
@@ -3629,7 +3629,7 @@ static enum watch_result our_htlc_depth(struct peer *peer,
|
||||
|
||||
height = get_block_height(peer->dstate);
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* If the *commitment tx* is the other node's, the output is
|
||||
* considered *timed out* once the HTLC is expired. If the
|
||||
@@ -3645,7 +3645,7 @@ static enum watch_result our_htlc_depth(struct peer *peer,
|
||||
return KEEP_WATCHING;
|
||||
}
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* If the output has *timed out* and not been *resolved*, the node
|
||||
* MUST *resolve* the output by spending it.
|
||||
@@ -3692,7 +3692,7 @@ static enum watch_result their_htlc_depth(struct peer *peer,
|
||||
|
||||
height = get_block_height(peer->dstate);
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* Otherwise, if the output HTLC has expired, it is considered
|
||||
* *irrevocably resolved*.
|
||||
@@ -3715,7 +3715,7 @@ static enum watch_result our_main_output_depth(struct peer *peer,
|
||||
|
||||
assert(peer->onchain.to_us_idx != -1);
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 1. _A's main output_: A node SHOULD spend this output to a
|
||||
* convenient address. This avoids having to remember the
|
||||
@@ -3767,7 +3767,7 @@ static enum watch_result our_htlc_spent(struct peer *peer,
|
||||
struct sha256 sha;
|
||||
struct rval preimage;
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* If a node sees a redemption transaction...the node MUST extract the
|
||||
* preimage from the transaction input witness. This is either to
|
||||
@@ -3801,7 +3801,7 @@ static enum watch_result our_htlc_spent(struct peer *peer,
|
||||
set_htlc_rval(peer, h, &preimage);
|
||||
our_htlc_fulfilled(peer, h);
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* If a node sees a redemption transaction, the output is considered
|
||||
* *irrevocably resolved*... Note that we don't care about the fate of
|
||||
@@ -3820,7 +3820,7 @@ static void resolve_our_htlc(struct peer *peer,
|
||||
const struct sha256_double*,
|
||||
ptrint_t *out_num))
|
||||
{
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* A node MUST watch for spends of *commitment tx* outputs for HTLCs
|
||||
* it offered; each one must be *resolved* by a timeout transaction
|
||||
@@ -3835,7 +3835,7 @@ static void resolve_our_htlc(struct peer *peer,
|
||||
|
||||
static void resolve_their_htlc(struct peer *peer, unsigned int out_num)
|
||||
{
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* If the node ... already knows... a redemption preimage for an
|
||||
* unresolved *commitment tx* output it was offered, it MUST *resolve*
|
||||
@@ -3845,7 +3845,7 @@ static void resolve_their_htlc(struct peer *peer, unsigned int out_num)
|
||||
peer->onchain.resolved[out_num] = htlc_fulfill_tx(peer, out_num);
|
||||
broadcast_tx(peer, peer->onchain.resolved[out_num], NULL);
|
||||
} else {
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* Otherwise, if the output HTLC has expired, it is considered
|
||||
* *irrevocably resolved*.
|
||||
@@ -3855,7 +3855,7 @@ static void resolve_their_htlc(struct peer *peer, unsigned int out_num)
|
||||
}
|
||||
}
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* When node A sees its own *commitment tx*:
|
||||
*/
|
||||
@@ -3870,7 +3870,7 @@ static void resolve_our_unilateral(struct peer *peer)
|
||||
watch_tx(tx, peer, tx, our_unilateral_depth, NULL);
|
||||
|
||||
for (i = 0; i < tx->output_count; i++) {
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 1. _A's main output_: A node SHOULD spend this output to a
|
||||
* convenient address. ... A node MUST wait until the
|
||||
@@ -3881,7 +3881,7 @@ static void resolve_our_unilateral(struct peer *peer)
|
||||
if (i == peer->onchain.to_us_idx)
|
||||
watch_tx(tx, peer, tx, our_main_output_depth, NULL);
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 2. _B's main output_: No action required, this output is
|
||||
* considered *resolved* by the *commitment tx*.
|
||||
@@ -3889,7 +3889,7 @@ static void resolve_our_unilateral(struct peer *peer)
|
||||
else if (i == peer->onchain.to_them_idx)
|
||||
peer->onchain.resolved[i] = tx;
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 3. _A's offered HTLCs_: See On-chain HTLC Handling: Our
|
||||
* Offers below.
|
||||
@@ -3897,7 +3897,7 @@ static void resolve_our_unilateral(struct peer *peer)
|
||||
else if (htlc_owner(peer->onchain.htlcs[i]) == LOCAL)
|
||||
resolve_our_htlc(peer, i, our_htlc_depth_ourcommit);
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 4. _B's offered HTLCs_: See On-chain HTLC Handling: Their
|
||||
* Offers below.
|
||||
@@ -3907,7 +3907,7 @@ static void resolve_our_unilateral(struct peer *peer)
|
||||
}
|
||||
}
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* Similarly, when node A sees a *commitment tx* from B:
|
||||
*/
|
||||
@@ -3917,7 +3917,7 @@ static void resolve_their_unilateral(struct peer *peer)
|
||||
const struct bitcoin_tx *tx = peer->onchain.tx;
|
||||
|
||||
for (i = 0; i < tx->output_count; i++) {
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 1. _A's main output_: No action is required; this is a
|
||||
* simple P2WPKH output. This output is considered
|
||||
@@ -3925,14 +3925,14 @@ static void resolve_their_unilateral(struct peer *peer)
|
||||
*/
|
||||
if (i == peer->onchain.to_us_idx)
|
||||
peer->onchain.resolved[i] = tx;
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 2. _B's main output_: No action required, this output is
|
||||
* considered *resolved* by the *commitment tx*.
|
||||
*/
|
||||
else if (i == peer->onchain.to_them_idx)
|
||||
peer->onchain.resolved[i] = tx;
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 3. _A's offered HTLCs_: See On-chain HTLC Handling: Our
|
||||
* Offers below.
|
||||
@@ -3952,10 +3952,10 @@ static void resolve_mutual_close(struct peer *peer)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* A node doesn't need to do anything else as it has already agreed to
|
||||
* the output, which is sent to its specified scriptpubkey (see BOLT
|
||||
* the output, which is sent to its specified scriptpubkey (see FIXME-OLD
|
||||
* #2 "4.1: Closing initiation: close_shutdown").
|
||||
*/
|
||||
for (i = 0; i < peer->onchain.tx->output_count; i++)
|
||||
@@ -3976,7 +3976,7 @@ static enum watch_result check_for_resolution(struct peer *peer,
|
||||
size_t i, n = tal_count(peer->onchain.resolved);
|
||||
size_t forever = peer->dstate->config.forever_confirms;
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* A node MUST *resolve* all outputs as specified below, and MUST be
|
||||
* prepared to resolve them multiple times in case of blockchain
|
||||
@@ -3986,7 +3986,7 @@ static enum watch_result check_for_resolution(struct peer *peer,
|
||||
if (!peer->onchain.resolved[i])
|
||||
return KEEP_WATCHING;
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* Outputs which are *resolved* by a transaction are considered
|
||||
* *irrevocably resolved* once they are included in a block at least
|
||||
@@ -4003,7 +4003,7 @@ static enum watch_result check_for_resolution(struct peer *peer,
|
||||
return KEEP_WATCHING;
|
||||
}
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* A node MUST monitor the blockchain for transactions which spend any
|
||||
* output which is not *irrevocably resolved* until all outputs are
|
||||
@@ -4057,7 +4057,7 @@ static void resolve_their_steal(struct peer *peer,
|
||||
|
||||
log_debug(peer->log, "Analyzing tx to steal:");
|
||||
for (i = 0; i < tx->output_count; i++) {
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
* 1. _A's main output_: No action is required; this is a
|
||||
* simple P2WPKH output. This output is considered
|
||||
* *resolved* by the *commitment tx*.
|
||||
@@ -4068,7 +4068,7 @@ static void resolve_their_steal(struct peer *peer,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* 2. _B's main output_: The node MUST *resolve* this by
|
||||
* spending using the revocation preimage.
|
||||
@@ -4253,7 +4253,7 @@ static enum watch_result anchor_spent(struct peer *peer,
|
||||
goto unknown_spend;
|
||||
}
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* A node MAY send a descriptive error packet in this case.
|
||||
*/
|
||||
@@ -4266,7 +4266,7 @@ static enum watch_result anchor_spent(struct peer *peer,
|
||||
/* If we've just closed connection, make output close it. */
|
||||
io_wake(peer);
|
||||
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* A node SHOULD fail the connection if it is not already
|
||||
* closed when it sees the funding transaction spent.
|
||||
@@ -4279,7 +4279,7 @@ static enum watch_result anchor_spent(struct peer *peer,
|
||||
return KEEP_WATCHING;
|
||||
|
||||
unknown_spend:
|
||||
/* BOLT #onchain:
|
||||
/* FIXME-OLD #onchain:
|
||||
*
|
||||
* A node SHOULD report an error to the operator if it
|
||||
* sees a transaction spend the funding transaction
|
||||
|
||||
@@ -60,7 +60,7 @@ static inline bool state_can_commit(enum state s)
|
||||
return s == STATE_NORMAL || s == STATE_SHUTDOWN;
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT send a `update_add_htlc` after a `close_shutdown`
|
||||
*/
|
||||
|
||||
@@ -638,7 +638,7 @@ static void send_commit(struct peer *peer)
|
||||
{ SENT_REMOVE_HTLC, SENT_REMOVE_COMMIT}
|
||||
};
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* An implementation MAY choose not to send an `update_commit`
|
||||
* until it receives the `update_revocation` response to the
|
||||
@@ -647,14 +647,14 @@ static void send_commit(struct peer *peer)
|
||||
if (peer->remote->prev && !peer->remote->prev->revoked)
|
||||
errx(1, "%s: commit: must wait for previous commit", peer->name);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* ...a sending node MUST apply all remote acked and unacked
|
||||
* changes except unacked fee changes to the remote commitment
|
||||
* before generating `sig`.
|
||||
*/
|
||||
if (!change_htlcs(peer, changes, true)) {
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT send an `update_commit` message which does
|
||||
* not include any updates.
|
||||
@@ -708,7 +708,7 @@ static void receive_revoke(struct peer *peer, u32 number)
|
||||
db_recv_remote_revoke(&peer->db, ci);
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* the receiving node MUST add the HTLC addition to the unacked
|
||||
* changeset for its local commitment.
|
||||
@@ -721,7 +721,7 @@ static void receive_offer(struct peer *peer, unsigned int htlc)
|
||||
record_recv(peer, "add_htlc %u", h->id);
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* the receiving node MUST add the HTLC fulfill/fail to the unacked
|
||||
* changeset for its local commitment.
|
||||
@@ -738,7 +738,7 @@ static void receive_remove(struct peer *peer, unsigned int htlc)
|
||||
record_recv(peer, "fulfill_htlc %u", h->id);
|
||||
}
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* the receiving node MUST add the fee change to the unacked changeset
|
||||
* for its local commitment.
|
||||
@@ -792,7 +792,7 @@ static void receive_commit(struct peer *peer, const struct signature *sig)
|
||||
|
||||
record_recv(peer, "update_commit");
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME-OLD #2:
|
||||
*
|
||||
* A node MUST NOT send an `update_commit` message which does
|
||||
* not include any updates.
|
||||
|
||||
Reference in New Issue
Block a user