mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
BOLT update to fae35903ae600d61124a3920363094b02d2ae8e5
This details handling of onchain HTLCs, and we document how we implement it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1115,6 +1115,19 @@ static void onchaind_tell_fulfill(struct peer *peer)
|
|||||||
if (hin->key.peer != peer)
|
if (hin->key.peer != peer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* BOLT #5:
|
||||||
|
*
|
||||||
|
* If the node receives (or already knows) a payment preimage
|
||||||
|
* for an unresolved HTLC output it was offered for which it
|
||||||
|
* has committed to an outgoing HTLC, it MUST *resolve* the
|
||||||
|
* output by spending it. Otherwise, if the other node is not
|
||||||
|
* irrevocably committed to the HTLC, it MUST NOT *resolve*
|
||||||
|
* the output by spending it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* We only set preimage once it's irrevocably committed, and
|
||||||
|
* we spend even if we don't have an outgoing HTLC (eg. local
|
||||||
|
* payyment complete) */
|
||||||
if (!hin->preimage)
|
if (!hin->preimage)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -774,9 +774,12 @@ static void tx_new_depth(struct tracked_output **outs,
|
|||||||
/* BOLT #5:
|
/* BOLT #5:
|
||||||
*
|
*
|
||||||
* If the node receives (or already knows) a payment preimage for an
|
* If the node receives (or already knows) a payment preimage for an
|
||||||
* unresolved HTLC output it was offered, it MUST *resolve* the output by
|
* unresolved HTLC output it was offered for which it has committed to an
|
||||||
* spending it.
|
* outgoing HTLC, it MUST *resolve* the output by spending it. Otherwise, if
|
||||||
|
* the other node is not irrevocably committed to the HTLC, it MUST NOT
|
||||||
|
* *resolve* the output by spending it.
|
||||||
*/
|
*/
|
||||||
|
/* Master makes sure we only get told preimages once other node is committed. */
|
||||||
static void handle_preimage(struct tracked_output **outs,
|
static void handle_preimage(struct tracked_output **outs,
|
||||||
const struct preimage *preimage)
|
const struct preimage *preimage)
|
||||||
{
|
{
|
||||||
@@ -812,11 +815,11 @@ static void handle_preimage(struct tracked_output **outs,
|
|||||||
|
|
||||||
/* BOLT #5:
|
/* BOLT #5:
|
||||||
*
|
*
|
||||||
* If the transaction is the nodes' own commitment
|
* To spend an offered HTLC output: if the transaction is the
|
||||||
* transaction, then the it MUST use the HTLC-success
|
* nodes' own commitment transaction, then it MUST use the
|
||||||
* transaction, and the HTLC-success transaction output MUST
|
* HTLC-success transaction, and the HTLC-success transaction
|
||||||
* be *resolved* as described in "On-chain HTLC Transaction
|
* output MUST be *resolved* as described in "On-chain HTLC
|
||||||
* Handling".
|
* Transaction Handling"
|
||||||
*/
|
*/
|
||||||
if (outs[i]->remote_htlc_sig) {
|
if (outs[i]->remote_htlc_sig) {
|
||||||
tx = htlc_success_tx(outs[i], &outs[i]->txid,
|
tx = htlc_success_tx(outs[i], &outs[i]->txid,
|
||||||
@@ -839,8 +842,8 @@ static void handle_preimage(struct tracked_output **outs,
|
|||||||
} else {
|
} else {
|
||||||
/* BOLT #5:
|
/* BOLT #5:
|
||||||
*
|
*
|
||||||
* Otherwise, it MUST *resolve* the output by spending
|
* otherwise, it MUST spend the output to a convenient
|
||||||
* it to a convenient address.
|
* address.
|
||||||
*/
|
*/
|
||||||
tx = tx_to_us(outs[i], outs[i], 0, 0,
|
tx = tx_to_us(outs[i], outs[i], 0, 0,
|
||||||
preimage, sizeof(*preimage),
|
preimage, sizeof(*preimage),
|
||||||
@@ -1015,18 +1018,9 @@ static void resolve_their_htlc(struct tracked_output *out)
|
|||||||
*
|
*
|
||||||
*...
|
*...
|
||||||
* ## Requirements
|
* ## Requirements
|
||||||
*
|
*...
|
||||||
*
|
* If not otherwise resolved, once the HTLC output has expired, it is
|
||||||
* If the node receives (or already knows) a payment preimage for an
|
* considered *irrevocably resolved*.
|
||||||
* unresolved HTLC output it was offered, it MUST *resolve* the output
|
|
||||||
* by spending it. If the transaction is the nodes' own commitment
|
|
||||||
* transaction, then the it MUST use the HTLC-success transaction, and
|
|
||||||
* the HTLC-success transaction output MUST be *resolved* as described
|
|
||||||
* in "On-chain HTLC Transaction Handling". Otherwise, it MUST
|
|
||||||
* *resolve* the output by spending it to a convenient address.
|
|
||||||
*
|
|
||||||
* Otherwise, if the HTLC output has expired, it is considered
|
|
||||||
* *irrevocably resolved*.
|
|
||||||
*/
|
*/
|
||||||
/* If we hit timeout depth, resolve by ignoring. */
|
/* If we hit timeout depth, resolve by ignoring. */
|
||||||
propose_resolution_at_block(out, NULL, out->htlc->cltv_expiry,
|
propose_resolution_at_block(out, NULL, out->htlc->cltv_expiry,
|
||||||
|
|||||||
Reference in New Issue
Block a user