mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
channeld: Add dynamic funding_pubkeys to channel_txs
In anticipation of adding support for rotating funding pubkeys during a splice, `channel_txs` is updated to support specifying these manually instead of using the channel’s funding pubkeys. Changelog-None
This commit is contained in:
parent
42440e3bee
commit
a21ae33b2d
@ -1166,7 +1166,8 @@ static u8 *send_commit_part(const tal_t *ctx,
|
||||
direct_outputs, &funding_wscript,
|
||||
peer->channel, remote_per_commit,
|
||||
remote_index, REMOTE,
|
||||
splice_amnt, remote_splice_amnt, &local_anchor_outnum);
|
||||
splice_amnt, remote_splice_amnt, &local_anchor_outnum,
|
||||
NULL);
|
||||
htlc_sigs =
|
||||
calc_commitsigs(tmpctx, peer, txs, funding_wscript, htlc_map,
|
||||
remote_index, remote_per_commit, &commit_sig);
|
||||
@ -1935,7 +1936,8 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
|
||||
NULL, &funding_wscript, peer->channel,
|
||||
local_per_commit,
|
||||
local_index, LOCAL, splice_amnt,
|
||||
remote_splice_amnt, &remote_anchor_outnum);
|
||||
remote_splice_amnt, &remote_anchor_outnum,
|
||||
NULL);
|
||||
|
||||
/* Set the commit_sig on the commitment tx psbt */
|
||||
if (!psbt_input_set_signature(txs[0]->psbt, 0,
|
||||
|
@ -309,13 +309,17 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
enum side side,
|
||||
s64 splice_amnt,
|
||||
s64 remote_splice_amnt,
|
||||
int *other_anchor_outnum)
|
||||
int *other_anchor_outnum,
|
||||
const struct pubkey funding_pubkeys[NUM_SIDES])
|
||||
{
|
||||
struct bitcoin_tx **txs;
|
||||
const struct htlc **committed;
|
||||
struct keyset keyset;
|
||||
struct amount_msat side_pay, other_side_pay;
|
||||
|
||||
if (!funding_pubkeys)
|
||||
funding_pubkeys = channel->funding_pubkey;
|
||||
|
||||
if (!derive_keyset(per_commitment_point,
|
||||
&channel->basepoints[side],
|
||||
&channel->basepoints[!side],
|
||||
@ -329,8 +333,8 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
/* Generating and saving witness script required to spend
|
||||
* the funding output */
|
||||
*funding_wscript = bitcoin_redeem_2of2(ctx,
|
||||
&channel->funding_pubkey[side],
|
||||
&channel->funding_pubkey[!side]);
|
||||
&funding_pubkeys[side],
|
||||
&funding_pubkeys[!side]);
|
||||
|
||||
side_pay = channel->view[side].owed[side];
|
||||
other_side_pay = channel->view[side].owed[!side];
|
||||
@ -351,8 +355,8 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
txs[0] = commit_tx(
|
||||
txs, funding,
|
||||
funding_sats,
|
||||
&channel->funding_pubkey[side],
|
||||
&channel->funding_pubkey[!side],
|
||||
&funding_pubkeys[side],
|
||||
&funding_pubkeys[!side],
|
||||
channel->opener,
|
||||
channel->config[!side].to_self_delay,
|
||||
channel->lease_expiry,
|
||||
@ -367,9 +371,9 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
|
||||
/* Set the remote/local pubkeys on the commitment tx psbt */
|
||||
psbt_input_add_pubkey(txs[0]->psbt, 0,
|
||||
&channel->funding_pubkey[side], false /* is_taproot */);
|
||||
&funding_pubkeys[side], false /* is_taproot */);
|
||||
psbt_input_add_pubkey(txs[0]->psbt, 0,
|
||||
&channel->funding_pubkey[!side], false /* is_taproot */);
|
||||
&funding_pubkeys[!side], false /* is_taproot */);
|
||||
|
||||
add_htlcs(&txs, *htlcmap, channel, &keyset, side);
|
||||
|
||||
|
@ -67,6 +67,7 @@ struct channel *new_full_channel(const tal_t *ctx,
|
||||
* @local_splice_amnt: how much is being spliced in (or out, if -ve) of local side.
|
||||
* @remote_splice_amnt: how much is being spliced in (or out, if -ve) of remote side.
|
||||
* @other_anchor_outnum: which output (-1 if none) is the !!side anchor
|
||||
* @funding_pubkeys: The funding pubkeys (specify NULL to use channel's value).
|
||||
*
|
||||
* Returns the unsigned commitment transaction for the committed state
|
||||
* for @side, followed by the htlc transactions in output order and
|
||||
@ -84,7 +85,8 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
enum side side,
|
||||
s64 local_splice_amnt,
|
||||
s64 remote_splice_amnt,
|
||||
int *local_anchor_outnum);
|
||||
int *local_anchor_outnum,
|
||||
const struct pubkey funding_pubkeys[NUM_SIDES]);
|
||||
|
||||
/**
|
||||
* actual_feerate: what is the actual feerate for the local side.
|
||||
|
@ -555,7 +555,7 @@ int main(int argc, const char *argv[])
|
||||
txs = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript_alt,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
assert(tal_count(txs) == 1);
|
||||
assert(tal_count(htlc_map) == 2);
|
||||
assert(scripteq(funding_wscript_alt, funding_wscript));
|
||||
@ -564,7 +564,7 @@ int main(int argc, const char *argv[])
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
|
||||
/* BOLT #3:
|
||||
@ -593,12 +593,12 @@ int main(int argc, const char *argv[])
|
||||
txs = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
assert(tal_count(txs) == 1);
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
|
||||
update_feerate(lchannel, feerate_per_kw[LOCAL]);
|
||||
@ -615,12 +615,12 @@ int main(int argc, const char *argv[])
|
||||
txs = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
assert(tal_count(txs) == 6);
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
|
||||
/* FIXME: Compare signatures! */
|
||||
@ -695,14 +695,14 @@ int main(int argc, const char *argv[])
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42,
|
||||
LOCAL, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
tx_must_be_eq(txs[0], raw_tx);
|
||||
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point,
|
||||
42, REMOTE, 0, 0,
|
||||
&local_anchor);
|
||||
&local_anchor, NULL);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ int main(int argc, char *argv[])
|
||||
local_txs = channel_txs(NULL, &channel->funding, channel->funding_sats,
|
||||
&htlcmap, NULL, &funding_wscript, channel,
|
||||
&local_per_commit_point, commitnum,
|
||||
LOCAL, 0, 0, &local_anchor_outnum);
|
||||
LOCAL, 0, 0, &local_anchor_outnum, NULL);
|
||||
|
||||
printf("## local_commitment\n"
|
||||
"# input amount %s, funding_wscript %s, pubkey %s\n",
|
||||
@ -536,7 +536,7 @@ int main(int argc, char *argv[])
|
||||
remote_txs = channel_txs(NULL, &channel->funding, channel->funding_sats,
|
||||
&htlcmap, NULL, &funding_wscript, channel,
|
||||
&remote_per_commit_point, commitnum,
|
||||
REMOTE, 0, 0, &local_anchor_outnum);
|
||||
REMOTE, 0, 0, &local_anchor_outnum, NULL);
|
||||
|
||||
printf("## remote_commitment\n"
|
||||
"# input amount %s, funding_wscript %s, key %s\n",
|
||||
|
Loading…
Reference in New Issue
Block a user