mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
channeld: rename channel_splice_txs to channel_txs.
channel_txs was a thin wrapper around channel_splice_txs, but that's just confusing. Rename channel_splice_txs to channel_txs, and just call it everywhere. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
1d4ae91d2c
commit
9b3965c805
5 changed files with 53 additions and 68 deletions
|
@ -1533,7 +1533,7 @@ static u8 *send_commit_part(struct peer *peer,
|
|||
derive_channel_id(cs_tlv->splice_info, funding);
|
||||
}
|
||||
|
||||
txs = channel_splice_txs(tmpctx, funding, funding_sats, &htlc_map,
|
||||
txs = channel_txs(tmpctx, funding, funding_sats, &htlc_map,
|
||||
direct_outputs, &funding_wscript,
|
||||
peer->channel, &peer->remote_per_commit,
|
||||
remote_index, REMOTE,
|
||||
|
@ -2047,7 +2047,7 @@ static struct commitsig *handle_peer_commit_sig(struct peer *peer,
|
|||
funding_sats = peer->channel->funding_sats;
|
||||
}
|
||||
|
||||
txs = channel_splice_txs(tmpctx, &outpoint, funding_sats, &htlc_map,
|
||||
txs = channel_txs(tmpctx, &outpoint, funding_sats, &htlc_map,
|
||||
NULL, &funding_wscript, peer->channel,
|
||||
&peer->next_local_per_commit,
|
||||
peer->next_index[LOCAL], LOCAL, splice_amnt,
|
||||
|
|
|
@ -299,21 +299,6 @@ static void add_htlcs(struct bitcoin_tx ***txs,
|
|||
|
||||
/* FIXME: We could cache these. */
|
||||
struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
const struct htlc ***htlcmap,
|
||||
struct wally_tx_output *direct_outputs[NUM_SIDES],
|
||||
const u8 **funding_wscript,
|
||||
const struct channel *channel,
|
||||
const struct pubkey *per_commitment_point,
|
||||
u64 commitment_number,
|
||||
enum side side)
|
||||
{
|
||||
return channel_splice_txs(ctx, &channel->funding, channel->funding_sats,
|
||||
htlcmap, direct_outputs, funding_wscript,
|
||||
channel, per_commitment_point,
|
||||
commitment_number, side, 0, 0);
|
||||
}
|
||||
|
||||
struct bitcoin_tx **channel_splice_txs(const tal_t *ctx,
|
||||
const struct bitcoin_outpoint *funding,
|
||||
struct amount_sat funding_sats,
|
||||
const struct htlc ***htlcmap,
|
||||
|
|
|
@ -55,31 +55,23 @@ struct channel *new_full_channel(const tal_t *ctx,
|
|||
/**
|
||||
* channel_txs: Get the current commitment and htlc txs for the channel.
|
||||
* @ctx: tal context to allocate return value from.
|
||||
* @channel: The channel to evaluate
|
||||
* @funding: the outpoint we're spending
|
||||
* @funding_sats: the amount of @funding
|
||||
* @htlc_map: Pointer to htlcs for each tx output (allocated off @ctx).
|
||||
* @direct_outputs: If non-NULL, fill with pointers to the direct (non-HTLC) outputs (or NULL if none).
|
||||
* @funding_wscript: Pointer to wscript for the funding tx output
|
||||
* @channel: The channel to evaluate
|
||||
* @per_commitment_point: Per-commitment point to determine keys
|
||||
* @commitment_number: The index of this commitment.
|
||||
* @side: which side to get the commitment transaction for
|
||||
* @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.
|
||||
*
|
||||
* Returns the unsigned commitment transaction for the committed state
|
||||
* for @side, followed by the htlc transactions in output order and
|
||||
* fills in @htlc_map, or NULL on key derivation failure.
|
||||
*/
|
||||
struct bitcoin_tx **channel_txs(const tal_t *ctx,
|
||||
const struct htlc ***htlcmap,
|
||||
struct wally_tx_output *direct_outputs[NUM_SIDES],
|
||||
const u8 **funding_wscript,
|
||||
const struct channel *channel,
|
||||
const struct pubkey *per_commitment_point,
|
||||
u64 commitment_number,
|
||||
enum side side);
|
||||
|
||||
/* Version of `channel_txs` that lets you specify a custom funding outpoint
|
||||
* and funding_sats.
|
||||
*/
|
||||
struct bitcoin_tx **channel_splice_txs(const tal_t *ctx,
|
||||
const struct bitcoin_outpoint *funding,
|
||||
struct amount_sat funding_sats,
|
||||
const struct htlc ***htlcmap,
|
||||
|
@ -89,7 +81,7 @@ struct bitcoin_tx **channel_splice_txs(const tal_t *ctx,
|
|||
const struct pubkey *per_commitment_point,
|
||||
u64 commitment_number,
|
||||
enum side side,
|
||||
s64 splice_amnt,
|
||||
s64 local_splice_amnt,
|
||||
s64 remote_splice_amnt);
|
||||
|
||||
/**
|
||||
|
|
|
@ -537,17 +537,17 @@ int main(int argc, const char *argv[])
|
|||
NULL, &htlc_map, NULL, 0x2bb038521914 ^ 42,
|
||||
option_anchor_outputs, option_anchors_zero_fee_htlc_tx, LOCAL);
|
||||
|
||||
txs = channel_txs(tmpctx,
|
||||
txs = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript_alt,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL);
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL, 0, 0);
|
||||
assert(tal_count(txs) == 1);
|
||||
assert(tal_count(htlc_map) == 2);
|
||||
assert(scripteq(funding_wscript_alt, funding_wscript));
|
||||
tx_must_be_eq(txs[0], raw_tx);
|
||||
|
||||
txs2 = channel_txs(tmpctx,
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE);
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE, 0, 0);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
|
||||
/* BOLT #3:
|
||||
|
@ -573,11 +573,13 @@ int main(int argc, const char *argv[])
|
|||
assert(lchannel->view[REMOTE].owed[REMOTE].millisatoshis
|
||||
== rchannel->view[LOCAL].owed[LOCAL].millisatoshis);
|
||||
|
||||
txs = channel_txs(tmpctx, &htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL);
|
||||
txs = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL, 0, 0);
|
||||
assert(tal_count(txs) == 1);
|
||||
txs2 = channel_txs(tmpctx, &htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE);
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE, 0, 0);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
|
||||
update_feerate(lchannel, feerate_per_kw[LOCAL]);
|
||||
|
@ -591,11 +593,13 @@ int main(int argc, const char *argv[])
|
|||
assert(lchannel->view[REMOTE].owed[REMOTE].millisatoshis
|
||||
== rchannel->view[LOCAL].owed[LOCAL].millisatoshis);
|
||||
|
||||
txs = channel_txs(tmpctx, &htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL);
|
||||
txs = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42, LOCAL, 0, 0);
|
||||
assert(tal_count(txs) == 6);
|
||||
txs2 = channel_txs(tmpctx, &htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE);
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point, 42, REMOTE, 0, 0);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
|
||||
/* FIXME: Compare signatures! */
|
||||
|
@ -665,14 +669,16 @@ int main(int argc, const char *argv[])
|
|||
0x2bb038521914 ^ 42,
|
||||
option_anchor_outputs, option_anchors_zero_fee_htlc_tx, LOCAL);
|
||||
|
||||
txs = channel_txs(tmpctx, &htlc_map, NULL, &funding_wscript,
|
||||
txs = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
lchannel, &local_per_commitment_point, 42,
|
||||
LOCAL);
|
||||
LOCAL, 0, 0);
|
||||
tx_must_be_eq(txs[0], raw_tx);
|
||||
|
||||
txs2 = channel_txs(tmpctx, &htlc_map, NULL, &funding_wscript,
|
||||
txs2 = channel_txs(tmpctx, &funding, funding_amount,
|
||||
&htlc_map, NULL, &funding_wscript,
|
||||
rchannel, &local_per_commitment_point,
|
||||
42, REMOTE);
|
||||
42, REMOTE, 0, 0);
|
||||
txs_must_be_eq(txs, txs2);
|
||||
}
|
||||
|
||||
|
|
|
@ -422,9 +422,10 @@ int main(int argc, char *argv[])
|
|||
if (!per_commit_point(&localseed, &local_per_commit_point, commitnum))
|
||||
errx(1, "Bad deriving local per-commitment-point");
|
||||
|
||||
local_txs = channel_txs(NULL, &htlcmap, NULL, &funding_wscript, channel,
|
||||
local_txs = channel_txs(NULL, &channel->funding, channel->funding_sats,
|
||||
&htlcmap, NULL, &funding_wscript, channel,
|
||||
&local_per_commit_point, commitnum,
|
||||
LOCAL);
|
||||
LOCAL, 0, 0);
|
||||
|
||||
printf("## local_commitment\n"
|
||||
"# input amount %s, funding_wscript %s, pubkey %s\n",
|
||||
|
@ -532,9 +533,10 @@ int main(int argc, char *argv[])
|
|||
/* Create the remote commitment tx */
|
||||
if (!per_commit_point(&remoteseed, &remote_per_commit_point, commitnum))
|
||||
errx(1, "Bad deriving remote per-commitment-point");
|
||||
remote_txs = channel_txs(NULL, &htlcmap, NULL, &funding_wscript, channel,
|
||||
remote_txs = channel_txs(NULL, &channel->funding, channel->funding_sats,
|
||||
&htlcmap, NULL, &funding_wscript, channel,
|
||||
&remote_per_commit_point, commitnum,
|
||||
REMOTE);
|
||||
REMOTE, 0, 0);
|
||||
|
||||
printf("## remote_commitment\n"
|
||||
"# input amount %s, funding_wscript %s, key %s\n",
|
||||
|
|
Loading…
Add table
Reference in a new issue