mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
channeld: Code to implement splicing
Update the lightningd <-> channeld interface with lots of new commands to needed to facilitate spicing. Implement the channeld splicing protocol leveraging the interactivetx protocol. Implement lightningd’s channel_control to support channeld in its splicing efforts. Changelog-Added: Added the features to enable splicing & resizing of active channels.
This commit is contained in:
committed by
Rusty Russell
parent
ebd0a3fd69
commit
4628e3ace8
@@ -760,14 +760,14 @@ static char *check_balances(const tal_t *ctx,
|
||||
assert(ok);
|
||||
|
||||
initiator_weight +=
|
||||
psbt_input_weight(psbt, i);
|
||||
psbt_input_get_weight(psbt, i);
|
||||
} else {
|
||||
ok = amount_sat_add(&accepter_inputs,
|
||||
accepter_inputs, amt);
|
||||
assert(ok);
|
||||
|
||||
accepter_weight +=
|
||||
psbt_input_weight(psbt, i);
|
||||
psbt_input_get_weight(psbt, i);
|
||||
}
|
||||
}
|
||||
tot_output_amt = AMOUNT_SAT(0);
|
||||
@@ -826,13 +826,13 @@ static char *check_balances(const tal_t *ctx,
|
||||
}
|
||||
|
||||
initiator_weight +=
|
||||
psbt_output_weight(psbt, i);
|
||||
psbt_output_get_weight(psbt, i);
|
||||
} else {
|
||||
ok = amount_sat_add(&accepter_outs,
|
||||
accepter_outs, amt);
|
||||
assert(ok);
|
||||
accepter_weight +=
|
||||
psbt_output_weight(psbt, i);
|
||||
psbt_output_get_weight(psbt, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,7 +997,8 @@ static u8 *psbt_to_tx_sigs_msg(const tal_t *ctx,
|
||||
|
||||
return towire_tx_signatures(ctx, &state->channel_id,
|
||||
&state->tx_state->funding.txid,
|
||||
ws);
|
||||
ws,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void handle_tx_sigs(struct state *state, const u8 *msg)
|
||||
@@ -1009,10 +1010,12 @@ static void handle_tx_sigs(struct state *state, const u8 *msg)
|
||||
enum tx_role their_role = state->our_role == TX_INITIATOR ?
|
||||
TX_ACCEPTER : TX_INITIATOR;
|
||||
|
||||
struct tlv_txsigs_tlvs *txsig_tlvs = tlv_txsigs_tlvs_new(tmpctx);
|
||||
if (!fromwire_tx_signatures(tmpctx, msg, &cid, &txid,
|
||||
cast_const3(
|
||||
struct witness ***,
|
||||
&witnesses)))
|
||||
&witnesses),
|
||||
&txsig_tlvs))
|
||||
open_err_fatal(state, "Bad tx_signatures %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
@@ -1418,6 +1421,9 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state)
|
||||
case WIRE_PEER_STORAGE:
|
||||
case WIRE_YOUR_PEER_STORAGE:
|
||||
case WIRE_STFU:
|
||||
case WIRE_SPLICE:
|
||||
case WIRE_SPLICE_ACK:
|
||||
case WIRE_SPLICE_LOCKED:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1792,6 +1798,9 @@ static bool run_tx_interactive(struct state *state,
|
||||
case WIRE_PEER_STORAGE:
|
||||
case WIRE_YOUR_PEER_STORAGE:
|
||||
case WIRE_STFU:
|
||||
case WIRE_SPLICE:
|
||||
case WIRE_SPLICE_ACK:
|
||||
case WIRE_SPLICE_LOCKED:
|
||||
open_abort(state, "Unexpected wire message %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
return false;
|
||||
@@ -1873,7 +1882,7 @@ static u8 *accepter_commits(struct state *state,
|
||||
struct amount_msat our_msats;
|
||||
struct channel_id cid;
|
||||
const u8 *wscript;
|
||||
u8 *msg;
|
||||
u8 *msg, *commit_msg;
|
||||
char *error;
|
||||
|
||||
/* Find the funding transaction txid */
|
||||
@@ -1911,9 +1920,12 @@ static u8 *accepter_commits(struct state *state,
|
||||
}
|
||||
|
||||
remote_sig.sighash_type = SIGHASH_ALL;
|
||||
|
||||
struct tlv_commitment_signed_tlvs *cs_tlv
|
||||
= tlv_commitment_signed_tlvs_new(tmpctx);
|
||||
if (!fromwire_commitment_signed(tmpctx, msg, &cid,
|
||||
&remote_sig.s,
|
||||
&htlc_sigs))
|
||||
&htlc_sigs, &cs_tlv))
|
||||
open_err_fatal(state, "Parsing commitment signed %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
|
||||
@@ -2111,10 +2123,10 @@ static u8 *accepter_commits(struct state *state,
|
||||
master_badmsg(WIRE_DUALOPEND_SEND_TX_SIGS, msg);
|
||||
|
||||
/* Send our commitment sigs over now */
|
||||
peer_write(state->pps,
|
||||
take(towire_commitment_signed(NULL,
|
||||
&state->channel_id,
|
||||
&local_sig.s, NULL)));
|
||||
commit_msg = towire_commitment_signed(NULL, &state->channel_id,
|
||||
&local_sig.s, NULL, NULL);
|
||||
|
||||
peer_write(state->pps, take(commit_msg));
|
||||
tal_free(local_commit);
|
||||
return msg;
|
||||
}
|
||||
@@ -2757,7 +2769,7 @@ static u8 *opener_commits(struct state *state,
|
||||
assert(local_sig.sighash_type == SIGHASH_ALL);
|
||||
msg = towire_commitment_signed(tmpctx, &state->channel_id,
|
||||
&local_sig.s,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
peer_write(state->pps, msg);
|
||||
peer_billboard(false, "channel open: commitment sent, waiting for reply");
|
||||
|
||||
@@ -2770,9 +2782,12 @@ static u8 *opener_commits(struct state *state,
|
||||
}
|
||||
|
||||
remote_sig.sighash_type = SIGHASH_ALL;
|
||||
|
||||
struct tlv_commitment_signed_tlvs *cs_tlv
|
||||
= tlv_commitment_signed_tlvs_new(tmpctx);
|
||||
if (!fromwire_commitment_signed(tmpctx, msg, &cid,
|
||||
&remote_sig.s,
|
||||
&htlc_sigs))
|
||||
&htlc_sigs, &cs_tlv))
|
||||
open_err_fatal(state, "Parsing commitment signed %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
|
||||
@@ -4184,6 +4199,9 @@ static u8 *handle_peer_in(struct state *state)
|
||||
case WIRE_PEER_STORAGE:
|
||||
case WIRE_YOUR_PEER_STORAGE:
|
||||
case WIRE_STFU:
|
||||
case WIRE_SPLICE:
|
||||
case WIRE_SPLICE_ACK:
|
||||
case WIRE_SPLICE_LOCKED:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user