Skip to content

Commit

Permalink
fixup! channeld: Code to implement splicing
Browse files Browse the repository at this point in the history
* Clean up the locla & remote splice amounts in commit tx creation
* Add back feature options (lost in rebase)
* listpeerschannels man sha update
  • Loading branch information
ddustin committed May 15, 2023
1 parent a6da153 commit f47e177
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ static u8 *send_commit_part(struct peer *peer,
direct_outputs, &funding_wscript,
peer->channel, &peer->remote_per_commit,
peer->next_index[REMOTE], REMOTE,
remote_splice_amnt, splice_amnt);
splice_amnt, remote_splice_amnt);
htlc_sigs =
calc_commitsigs(tmpctx, peer, txs, funding_wscript, htlc_map,
peer->next_index[REMOTE], &commit_sig);
Expand Down
23 changes: 14 additions & 9 deletions channeld/full_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ struct bitcoin_tx **channel_splice_txs(const tal_t *ctx,
struct bitcoin_tx **txs;
const struct htlc **committed;
struct keyset keyset;
struct amount_msat self_pay, other_pay;
struct amount_msat side_pay, other_side_pay;

if (!derive_keyset(per_commitment_point,
&channel->basepoints[side],
Expand All @@ -339,25 +339,30 @@ struct bitcoin_tx **channel_splice_txs(const tal_t *ctx,
&channel->funding_pubkey[side],
&channel->funding_pubkey[!side]);

self_pay = channel->view[side].owed[side];
other_pay = channel->view[side].owed[!side];
side_pay = channel->view[side].owed[side];
other_side_pay = channel->view[side].owed[!side];

self_pay.millisatoshis += splice_amnt * 1000;
other_pay.millisatoshis += remote_splice_amnt * 1000;
if (side == LOCAL) {
side_pay.millisatoshis += splice_amnt * 1000;
other_side_pay.millisatoshis += remote_splice_amnt * 1000;
} else if (side == REMOTE) {
side_pay.millisatoshis += remote_splice_amnt * 1000;
other_side_pay.millisatoshis += splice_amnt * 1000;
}

txs = tal_arr(ctx, struct bitcoin_tx *, 1);
txs[0] = commit_tx(
ctx, &channel->funding,
channel->funding_sats,
ctx, funding,
funding_sats,
&channel->funding_pubkey[side],
&channel->funding_pubkey[!side],
channel->opener,
channel->config[!side].to_self_delay,
channel->lease_expiry,
channel_blockheight(channel, side),
&keyset, channel_feerate(channel, side),
channel->config[side].dust_limit, self_pay,
other_pay, committed, htlcmap, direct_outputs,
channel->config[side].dust_limit, side_pay,
other_side_pay, committed, htlcmap, direct_outputs,
commitment_number ^ channel->commitment_number_obscurer,
channel_has(channel, OPT_ANCHOR_OUTPUTS),
side);
Expand Down
4 changes: 4 additions & 0 deletions common/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ static const struct feature_style feature_styles[] = {
{ OPT_PROVIDE_PEER_BACKUP_STORAGE,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT } },
{ OPT_SPLICE,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
};

struct dependency {
Expand Down
2 changes: 1 addition & 1 deletion doc/lightning-listpeerchannels.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,4 @@ Main web site: <https://github.com/ElementsProject/lightning> Lightning
RFC site (BOLT \#9):
<https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md>

[comment]: # ( SHA256STAMP:78229c9896b65ad304ec8ed928a38ac54df9d8adb00d11a26169d9f9f2957798)
[comment]: # ( SHA256STAMP:f7b93b82fd618e2bd656e102b44c26ad9fdbe811b97ce8563e1768b5210688b7)

0 comments on commit f47e177

Please sign in to comment.