mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
channeld: fix up BOLT references.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
833e8387aa
commit
b40b6240ce
@@ -19,21 +19,24 @@ 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
|
||||
* owner, the commitment transaction MUST NOT contain that output,
|
||||
* otherwise it MUST be generated as specified in [Offered HTLC
|
||||
* Outputs](#offered-htlc-outputs).
|
||||
* - for every offered HTLC:
|
||||
* - if the HTLC amount minus the HTLC-timeout fee would be less than
|
||||
* `dust_limit_satoshis` set by the transaction owner:
|
||||
* - MUST NOT contain that output.
|
||||
* - otherwise:
|
||||
* - MUST be generated as specified in
|
||||
* [Offered HTLC Outputs](#offered-htlc-outputs).
|
||||
*/
|
||||
if (htlc_owner(htlc) == side)
|
||||
htlc_fee = htlc_timeout_fee(feerate_per_kw);
|
||||
/* 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
|
||||
* owner, the commitment transaction MUST NOT contain that output,
|
||||
* otherwise it MUST be generated as specified in [Received HTLC
|
||||
* Outputs](#received-htlc-outputs).
|
||||
* - for every received HTLC:
|
||||
* - if the HTLC amount minus the HTLC-success fee would be less than
|
||||
* `dust_limit_satoshis` set by the transaction owner:
|
||||
* - MUST NOT contain that output.
|
||||
* - otherwise:
|
||||
* - MUST be generated as specified in
|
||||
*/
|
||||
else
|
||||
htlc_fee = htlc_success_fee(feerate_per_kw);
|
||||
@@ -129,7 +132,7 @@ 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)).
|
||||
* `to_remote`), with a floor of 0 (see [Fee Payment](#fee-payment)).
|
||||
*/
|
||||
try_subtract_fee(funder, side, base_fee_msat,
|
||||
&self_pay_msat, &other_pay_msat);
|
||||
@@ -197,7 +200,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
||||
*
|
||||
* 5. If the `to_local` amount is greater or equal to
|
||||
* `dust_limit_satoshis`, add a [`to_local`
|
||||
* Output](#to-local-output).
|
||||
* output](#to-local-output).
|
||||
*/
|
||||
if (self_pay_msat / 1000 >= dust_limit_satoshis) {
|
||||
u8 *wscript = to_self_wscript(tmpctx, to_self_delay,keyset);
|
||||
@@ -215,15 +218,15 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
||||
*
|
||||
* 6. If the `to_remote` amount is greater or equal to
|
||||
* `dust_limit_satoshis`, add a [`to_remote`
|
||||
* Output](#to-remote-output).
|
||||
* output](#to-remote-output).
|
||||
*/
|
||||
if (other_pay_msat / 1000 >= dust_limit_satoshis) {
|
||||
/* BOLT #3:
|
||||
*
|
||||
* #### `to_remote` Output
|
||||
*
|
||||
* This output sends funds to the other peer, thus is a simple
|
||||
* P2WPKH to `remotekey`.
|
||||
* This output sends funds to the other peer and thus is a simple
|
||||
* P2WPKH to `remotepubkey`.
|
||||
*/
|
||||
tx->output[n].amount = other_pay_msat / 1000;
|
||||
tx->output[n].script = scriptpubkey_p2wpkh(tx,
|
||||
@@ -261,7 +264,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
||||
/* BOLT #3:
|
||||
*
|
||||
* * locktime: upper 8 bits are 0x20, lower 24 bits are the lower
|
||||
* 24 bits of the obscured commitment transaction number.
|
||||
* 24 bits of the obscured commitment transaction number
|
||||
*/
|
||||
tx->lock_time
|
||||
= (0x20000000 | (obscured_commitment_number & 0xFFFFFF));
|
||||
@@ -278,7 +281,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
||||
/* BOLT #3:
|
||||
*
|
||||
* * `txin[0]` sequence: upper 8 bits are 0x80, lower 24 bits are
|
||||
* upper 24 bits of the obscured commitment transaction number.
|
||||
* upper 24 bits of the obscured commitment transaction number
|
||||
*/
|
||||
tx->input[0].sequence_number
|
||||
= (0x80000000 | ((obscured_commitment_number>>24) & 0xFFFFFF));
|
||||
|
||||
Reference in New Issue
Block a user