Skip to content

Commit 32e6a29

Browse files
committed
df: rename 'funder' to 'opener'
Previously we've used the term 'funder' to refer to the peer paying the fees for a transaction; v2 of openchannel will make this no longer true. Instead we rename this to 'opener', or the peer sending the 'open_channel' message, since this will be universally true in a dual-funding world.
1 parent e65c1d9 commit 32e6a29

25 files changed

+138
-138
lines changed

channeld/channel_wire.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ msgdata,channel_init,remote_fundingkey,pubkey,
2222
msgdata,channel_init,remote_basepoints,basepoints,
2323
msgdata,channel_init,remote_per_commit,pubkey,
2424
msgdata,channel_init,old_remote_per_commit,pubkey,
25-
msgdata,channel_init,funder,enum side,
25+
msgdata,channel_init,opener,enum side,
2626
msgdata,channel_init,fee_base,u32,
2727
msgdata,channel_init,fee_proportional,u32,
2828
msgdata,channel_init,local_msatoshi,amount_msat,

channeld/channeld.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,10 @@ static void handle_peer_feechange(struct peer *peer, const u8 *msg)
669669
* - if the sender is not responsible for paying the Bitcoin fee:
670670
* - MUST fail the channel.
671671
*/
672-
if (peer->channel->funder != REMOTE)
672+
if (peer->channel->opener != REMOTE)
673673
peer_failed(peer->pps,
674674
&peer->channel_id,
675-
"update_fee from non-funder?");
675+
"update_fee from non-opener?");
676676

677677
status_debug("update_fee %u, range %u-%u",
678678
feerate, peer->feerate_min, peer->feerate_max);
@@ -1128,7 +1128,7 @@ static void send_commit(struct peer *peer)
11281128
}
11291129

11301130
/* If we wanted to update fees, do it now. */
1131-
if (peer->channel->funder == LOCAL) {
1131+
if (peer->channel->opener == LOCAL) {
11321132
u32 feerate, max = approx_max_feerate(peer->channel);
11331133

11341134
feerate = peer->desired_feerate;
@@ -1386,11 +1386,11 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg)
13861386
}
13871387

13881388
/* We were supposed to check this was affordable as we go. */
1389-
if (peer->channel->funder == REMOTE) {
1389+
if (peer->channel->opener == REMOTE) {
13901390
status_debug("Feerates are %u/%u",
13911391
peer->channel->view[LOCAL].feerate_per_kw,
13921392
peer->channel->view[REMOTE].feerate_per_kw);
1393-
assert(can_funder_afford_feerate(peer->channel,
1393+
assert(can_opener_afford_feerate(peer->channel,
13941394
peer->channel->view[LOCAL]
13951395
.feerate_per_kw));
13961396
}
@@ -1584,7 +1584,7 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
15841584
peer->old_remote_per_commit = peer->remote_per_commit;
15851585
peer->remote_per_commit = next_per_commit;
15861586
status_debug("revoke_and_ack %s: remote_per_commit = %s, old_remote_per_commit = %s",
1587-
side_to_str(peer->channel->funder),
1587+
side_to_str(peer->channel->opener),
15881588
type_to_string(tmpctx, struct pubkey,
15891589
&peer->remote_per_commit),
15901590
type_to_string(tmpctx, struct pubkey,
@@ -1992,7 +1992,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last
19921992
}
19931993

19941994
/* Make sure they have the correct fee. */
1995-
if (peer->channel->funder == LOCAL) {
1995+
if (peer->channel->opener == LOCAL) {
19961996
msg = towire_update_fee(NULL, &peer->channel_id,
19971997
channel_feerate(peer->channel, REMOTE));
19981998
sync_crypto_write(peer->pps, take(msg));
@@ -2519,7 +2519,7 @@ static void peer_reconnect(struct peer *peer,
25192519
* even tell by seeing if fees are different (short of saving full fee
25202520
* state in database) since it could be a tiny feechange, or two
25212521
* feechanges which cancelled out. */
2522-
if (peer->channel->funder == LOCAL)
2522+
if (peer->channel->opener == LOCAL)
25232523
peer->channel->changes_pending[LOCAL] = true;
25242524

25252525
peer_billboard(true, "Reconnected, and reestablished.");
@@ -2687,7 +2687,7 @@ static void handle_feerates(struct peer *peer, const u8 *inmsg)
26872687
* sufficient (by a significant margin) for timely processing of the
26882688
* commitment transaction.
26892689
*/
2690-
if (peer->channel->funder == LOCAL) {
2690+
if (peer->channel->opener == LOCAL) {
26912691
peer->desired_feerate = feerate;
26922692
start_commit_timer(peer);
26932693
} else {
@@ -2921,7 +2921,7 @@ static void init_channel(struct peer *peer)
29212921
struct pubkey funding_pubkey[NUM_SIDES];
29222922
struct channel_config conf[NUM_SIDES];
29232923
struct bitcoin_txid funding_txid;
2924-
enum side funder;
2924+
enum side opener;
29252925
enum htlc_state *hstates;
29262926
struct fulfilled_htlc *fulfilled;
29272927
enum side *fulfilled_sides;
@@ -2957,7 +2957,7 @@ static void init_channel(struct peer *peer)
29572957
&points[REMOTE],
29582958
&peer->remote_per_commit,
29592959
&peer->old_remote_per_commit,
2960-
&funder,
2960+
&opener,
29612961
&peer->fee_base,
29622962
&peer->fee_per_satoshi,
29632963
&local_msat,
@@ -3007,7 +3007,7 @@ static void init_channel(struct peer *peer)
30073007
" next_idx_remote = %"PRIu64
30083008
" revocations_received = %"PRIu64
30093009
" feerates %u/%u (range %u-%u)",
3010-
side_to_str(funder),
3010+
side_to_str(opener),
30113011
type_to_string(tmpctx, struct pubkey,
30123012
&peer->remote_per_commit),
30133013
type_to_string(tmpctx, struct pubkey,
@@ -3055,7 +3055,7 @@ static void init_channel(struct peer *peer)
30553055
&funding_pubkey[LOCAL],
30563056
&funding_pubkey[REMOTE],
30573057
option_static_remotekey,
3058-
funder);
3058+
opener);
30593059

30603060
if (!channel_force_htlcs(peer->channel, htlcs, hstates,
30613061
fulfilled, fulfilled_sides,
@@ -3083,7 +3083,7 @@ static void init_channel(struct peer *peer)
30833083
&peer->node_ids[REMOTE]);
30843084

30853085
/* Default desired feerate is the feerate we set for them last. */
3086-
if (peer->channel->funder == LOCAL)
3086+
if (peer->channel->opener == LOCAL)
30873087
peer->desired_feerate = feerate_per_kw[REMOTE];
30883088

30893089
/* from now we need keep watch over WIRE_CHANNEL_FUNDING_DEPTH */

channeld/commit_tx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
8080
const struct bitcoin_txid *funding_txid,
8181
unsigned int funding_txout,
8282
struct amount_sat funding,
83-
enum side funder,
83+
enum side opener,
8484
u16 to_self_delay,
8585
const struct keyset *keyset,
8686
u32 feerate_per_kw,
@@ -126,7 +126,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
126126
* 3. Subtract this base fee from the funder (either `to_local` or
127127
* `to_remote`), with a floor of 0 (see [Fee Payment](#fee-payment)).
128128
*/
129-
try_subtract_fee(funder, side, base_fee, &self_pay, &other_pay);
129+
try_subtract_fee(opener, side, base_fee, &self_pay, &other_pay);
130130

131131
#ifdef PRINT_ACTUAL_FEE
132132
{

channeld/commit_tx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ size_t commit_tx_num_untrimmed(const struct htlc **htlcs,
2828
* commit_tx: create (unsigned) commitment tx to spend the funding tx output
2929
* @ctx: context to allocate transaction and @htlc_map from.
3030
* @funding_txid, @funding_out, @funding: funding outpoint.
31-
* @funder: is the LOCAL or REMOTE paying the fee?
31+
* @opener: is the LOCAL or REMOTE paying the fee?
3232
* @keyset: keys derived for this commit tx.
3333
* @feerate_per_kw: feerate to use
3434
* @dust_limit: dust limit below which to trim outputs.
@@ -48,7 +48,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
4848
const struct bitcoin_txid *funding_txid,
4949
unsigned int funding_txout,
5050
struct amount_sat funding,
51-
enum side funder,
51+
enum side opener,
5252
u16 to_self_delay,
5353
const struct keyset *keyset,
5454
u32 feerate_per_kw,

channeld/full_channel.c

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct channel *new_full_channel(const tal_t *ctx,
4747
const struct pubkey *local_funding_pubkey,
4848
const struct pubkey *remote_funding_pubkey,
4949
bool option_static_remotekey,
50-
enum side funder)
50+
enum side opener)
5151
{
5252
struct channel *channel = new_initial_channel(ctx,
5353
chain_hash,
@@ -63,7 +63,7 @@ struct channel *new_full_channel(const tal_t *ctx,
6363
local_funding_pubkey,
6464
remote_funding_pubkey,
6565
option_static_remotekey,
66-
funder);
66+
opener);
6767

6868
if (channel) {
6969
/* Feerates can be different. */
@@ -283,7 +283,7 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
283283
txs = tal_arr(ctx, struct bitcoin_tx *, 1);
284284
txs[0] = commit_tx(
285285
ctx, chainparams, &channel->funding_txid, channel->funding_txout,
286-
channel->funding, channel->funder,
286+
channel->funding, channel->opener,
287287
channel->config[!side].to_self_delay, &keyset,
288288
channel->view[side].feerate_per_kw,
289289
channel->config[side].dust_limit, channel->view[side].owed[side],
@@ -459,7 +459,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
459459
*/
460460
/* Also we should not add more htlc's than sender or recipient
461461
* configured. This mitigates attacks in which a peer can force the
462-
* funder of the channel to pay unnecessary onchain fees during a fee
462+
* opener of the channel to pay unnecessary onchain fees during a fee
463463
* spike with large commitment transactions.
464464
*/
465465
min_concurrent_htlcs = channel->config[recipient].max_accepted_htlcs;
@@ -533,7 +533,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
533533
&balance))
534534
return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED;
535535

536-
if (channel->funder == sender) {
536+
if (channel->opener == sender) {
537537
if (amount_msat_less_sat(balance, fee)) {
538538
status_debug("Cannot afford fee %s with %s above reserve",
539539
type_to_string(tmpctx, struct amount_sat,
@@ -544,12 +544,12 @@ static enum channel_add_err add_htlc(struct channel *channel,
544544
}
545545
}
546546

547-
/* Try not to add a payment which will take funder into fees
547+
/* Try not to add a payment which will take opener into fees
548548
* on either our side or theirs. */
549549
if (sender == LOCAL) {
550550
if (!get_room_above_reserve(channel, view,
551551
adding, removing,
552-
channel->funder,
552+
channel->opener,
553553
&balance))
554554
return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED;
555555
/* Should be able to afford both their own commit tx
@@ -559,7 +559,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
559559
committed,
560560
adding,
561561
removing,
562-
channel->funder);
562+
channel->opener);
563563
/* set fee output pointer if given */
564564
if (htlc_fee && amount_sat_greater(fee, *htlc_fee))
565565
*htlc_fee = fee;
@@ -577,7 +577,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
577577
committed,
578578
adding,
579579
removing,
580-
!channel->funder);
580+
!channel->opener);
581581
/* set fee output pointer if given */
582582
if (htlc_fee && amount_sat_greater(fee, *htlc_fee))
583583
*htlc_fee = fee;
@@ -873,7 +873,7 @@ u32 approx_max_feerate(const struct channel *channel)
873873
struct amount_sat avail;
874874
const struct htlc **committed, **adding, **removing;
875875

876-
gather_htlcs(tmpctx, channel, !channel->funder,
876+
gather_htlcs(tmpctx, channel, !channel->opener,
877877
&committed, &removing, &adding);
878878

879879
/* Assume none are trimmed; this gives lower bound on feerate. */
@@ -883,28 +883,28 @@ u32 approx_max_feerate(const struct channel *channel)
883883

884884
/* We should never go below reserve. */
885885
if (!amount_sat_sub(&avail,
886-
amount_msat_to_sat_round_down(channel->view[!channel->funder].owed[channel->funder]),
887-
channel->config[!channel->funder].channel_reserve))
886+
amount_msat_to_sat_round_down(channel->view[!channel->opener].owed[channel->opener]),
887+
channel->config[!channel->opener].channel_reserve))
888888
avail = AMOUNT_SAT(0);
889889

890890
return avail.satoshis / weight * 1000; /* Raw: once-off reverse feerate*/
891891
}
892892

893-
bool can_funder_afford_feerate(const struct channel *channel, u32 feerate_per_kw)
893+
bool can_opener_afford_feerate(const struct channel *channel, u32 feerate_per_kw)
894894
{
895895
struct amount_sat needed, fee;
896-
struct amount_sat dust_limit = channel->config[!channel->funder].dust_limit;
896+
struct amount_sat dust_limit = channel->config[!channel->opener].dust_limit;
897897
size_t untrimmed;
898898
const struct htlc **committed, **adding, **removing;
899-
gather_htlcs(tmpctx, channel, !channel->funder,
899+
gather_htlcs(tmpctx, channel, !channel->opener,
900900
&committed, &removing, &adding);
901901

902902
untrimmed = commit_tx_num_untrimmed(committed, feerate_per_kw, dust_limit,
903-
!channel->funder)
903+
!channel->opener)
904904
+ commit_tx_num_untrimmed(adding, feerate_per_kw, dust_limit,
905-
!channel->funder)
905+
!channel->opener)
906906
- commit_tx_num_untrimmed(removing, feerate_per_kw, dust_limit,
907-
!channel->funder);
907+
!channel->opener);
908908

909909
fee = commit_tx_base_fee(feerate_per_kw, untrimmed);
910910

@@ -914,39 +914,39 @@ bool can_funder_afford_feerate(const struct channel *channel, u32 feerate_per_kw
914914
* node's current commitment transaction:
915915
* - SHOULD fail the channel
916916
*/
917-
/* Note: sender == funder */
917+
/* Note: sender == opener */
918918

919919
/* How much does it think it has? Must be >= reserve + fee */
920920
if (!amount_sat_add(&needed, fee,
921-
channel->config[!channel->funder].channel_reserve))
921+
channel->config[!channel->opener].channel_reserve))
922922
status_failed(STATUS_FAIL_INTERNAL_ERROR,
923923
"Cannot add fee %s and reserve %s",
924924
type_to_string(tmpctx, struct amount_sat,
925925
&fee),
926926
type_to_string(tmpctx, struct amount_sat,
927-
&channel->config[!channel->funder].channel_reserve));
927+
&channel->config[!channel->opener].channel_reserve));
928928

929929
status_debug("We need %s at feerate %u for %zu untrimmed htlcs: we have %s/%s",
930930
type_to_string(tmpctx, struct amount_sat, &needed),
931931
feerate_per_kw, untrimmed,
932932
type_to_string(tmpctx, struct amount_msat,
933-
&channel->view[LOCAL].owed[channel->funder]),
933+
&channel->view[LOCAL].owed[channel->opener]),
934934
type_to_string(tmpctx, struct amount_msat,
935-
&channel->view[REMOTE].owed[channel->funder]));
936-
return amount_msat_greater_eq_sat(channel->view[!channel->funder].owed[channel->funder],
935+
&channel->view[REMOTE].owed[channel->opener]));
936+
return amount_msat_greater_eq_sat(channel->view[!channel->opener].owed[channel->opener],
937937
needed);
938938
}
939939

940940
bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw)
941941
{
942-
if (!can_funder_afford_feerate(channel, feerate_per_kw))
942+
if (!can_opener_afford_feerate(channel, feerate_per_kw))
943943
return false;
944944

945945
status_debug("Setting %s feerate to %u",
946-
side_to_str(!channel->funder), feerate_per_kw);
946+
side_to_str(!channel->opener), feerate_per_kw);
947947

948-
channel->view[!channel->funder].feerate_per_kw = feerate_per_kw;
949-
channel->changes_pending[!channel->funder] = true;
948+
channel->view[!channel->opener].feerate_per_kw = feerate_per_kw;
949+
channel->changes_pending[!channel->opener] = true;
950950
return true;
951951
}
952952

@@ -994,8 +994,8 @@ bool channel_rcvd_revoke_and_ack(struct channel *channel,
994994
if (change & HTLC_LOCAL_F_PENDING)
995995
channel->changes_pending[LOCAL] = true;
996996

997-
/* For funder, ack also means time to apply new feerate locally. */
998-
if (channel->funder == LOCAL &&
997+
/* For opener, ack also means time to apply new feerate locally. */
998+
if (channel->opener == LOCAL &&
999999
(channel->view[LOCAL].feerate_per_kw
10001000
!= channel->view[REMOTE].feerate_per_kw)) {
10011001
status_debug("Applying feerate %u to LOCAL",
@@ -1045,8 +1045,8 @@ bool channel_sending_revoke_and_ack(struct channel *channel)
10451045
if (change & HTLC_REMOTE_F_PENDING)
10461046
channel->changes_pending[REMOTE] = true;
10471047

1048-
/* For non-funder, sending ack means we apply any fund changes to them */
1049-
if (channel->funder == REMOTE
1048+
/* For non-opener, sending ack means we apply any fund changes to them */
1049+
if (channel->opener == REMOTE
10501050
&& (channel->view[LOCAL].feerate_per_kw
10511051
!= channel->view[REMOTE].feerate_per_kw)) {
10521052
status_debug("Applying feerate %u to REMOTE",

0 commit comments

Comments
 (0)