Skip to content

Commit 0e20e3c

Browse files
niftyneirustyrussell
authored andcommitted
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 964a358 commit 0e20e3c

36 files changed

+243
-243
lines changed

channeld/channel_wire.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ msgdata,channel_init,remote_fundingkey,pubkey,
2424
msgdata,channel_init,remote_basepoints,basepoints,
2525
msgdata,channel_init,remote_per_commit,pubkey,
2626
msgdata,channel_init,old_remote_per_commit,pubkey,
27-
msgdata,channel_init,funder,enum side,
27+
msgdata,channel_init,opener,enum side,
2828
msgdata,channel_init,fee_base,u32,
2929
msgdata,channel_init,fee_proportional,u32,
3030
msgdata,channel_init,local_msatoshi,amount_msat,

channeld/channeld.c

+13-13
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);
@@ -975,7 +975,7 @@ static void send_commit(struct peer *peer)
975975
}
976976

977977
/* If we wanted to update fees, do it now. */
978-
if (peer->channel->funder == LOCAL) {
978+
if (peer->channel->opener == LOCAL) {
979979
u32 feerate, max = approx_max_feerate(peer->channel);
980980

981981
feerate = peer->desired_feerate;
@@ -1240,11 +1240,11 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg)
12401240
}
12411241

12421242
/* We were supposed to check this was affordable as we go. */
1243-
if (peer->channel->funder == REMOTE) {
1243+
if (peer->channel->opener == REMOTE) {
12441244
status_debug("Feerates are %u/%u",
12451245
channel_feerate(peer->channel, LOCAL),
12461246
channel_feerate(peer->channel, REMOTE));
1247-
assert(can_funder_afford_feerate(peer->channel,
1247+
assert(can_opener_afford_feerate(peer->channel,
12481248
channel_feerate(peer->channel,
12491249
LOCAL)));
12501250
}
@@ -1432,7 +1432,7 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg)
14321432
peer->old_remote_per_commit = peer->remote_per_commit;
14331433
peer->remote_per_commit = next_per_commit;
14341434
status_debug("revoke_and_ack %s: remote_per_commit = %s, old_remote_per_commit = %s",
1435-
side_to_str(peer->channel->funder),
1435+
side_to_str(peer->channel->opener),
14361436
type_to_string(tmpctx, struct pubkey,
14371437
&peer->remote_per_commit),
14381438
type_to_string(tmpctx, struct pubkey,
@@ -2107,7 +2107,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last
21072107
}
21082108

21092109
/* Make sure they have the correct fee. */
2110-
if (peer->channel->funder == LOCAL) {
2110+
if (peer->channel->opener == LOCAL) {
21112111
msg = towire_update_fee(NULL, &peer->channel_id,
21122112
channel_feerate(peer->channel, REMOTE));
21132113
sync_crypto_write(peer->pps, take(msg));
@@ -2812,7 +2812,7 @@ static void handle_feerates(struct peer *peer, const u8 *inmsg)
28122812
* sufficient (by a significant margin) for timely processing of the
28132813
* commitment transaction.
28142814
*/
2815-
if (peer->channel->funder == LOCAL) {
2815+
if (peer->channel->opener == LOCAL) {
28162816
peer->desired_feerate = feerate;
28172817
/* Don't do this for the first feerate, wait until something else
28182818
* happens. LND seems to get upset in some cases otherwise:
@@ -3067,7 +3067,7 @@ static void init_channel(struct peer *peer)
30673067
struct pubkey funding_pubkey[NUM_SIDES];
30683068
struct channel_config conf[NUM_SIDES];
30693069
struct bitcoin_txid funding_txid;
3070-
enum side funder;
3070+
enum side opener;
30713071
struct existing_htlc **htlcs;
30723072
bool reconnected;
30733073
u8 *funding_signed;
@@ -3102,7 +3102,7 @@ static void init_channel(struct peer *peer)
31023102
&points[REMOTE],
31033103
&peer->remote_per_commit,
31043104
&peer->old_remote_per_commit,
3105-
&funder,
3105+
&opener,
31063106
&peer->fee_base,
31073107
&peer->fee_per_satoshi,
31083108
&local_msat,
@@ -3148,7 +3148,7 @@ static void init_channel(struct peer *peer)
31483148
" next_idx_remote = %"PRIu64
31493149
" revocations_received = %"PRIu64
31503150
" feerates %s range %u-%u",
3151-
side_to_str(funder),
3151+
side_to_str(opener),
31523152
type_to_string(tmpctx, struct pubkey,
31533153
&peer->remote_per_commit),
31543154
type_to_string(tmpctx, struct pubkey,
@@ -3197,7 +3197,7 @@ static void init_channel(struct peer *peer)
31973197
&funding_pubkey[LOCAL],
31983198
&funding_pubkey[REMOTE],
31993199
option_static_remotekey,
3200-
funder);
3200+
opener);
32013201

32023202
if (!channel_force_htlcs(peer->channel,
32033203
cast_const2(const struct existing_htlc **, htlcs)))
@@ -3211,7 +3211,7 @@ static void init_channel(struct peer *peer)
32113211
&peer->node_ids[REMOTE]);
32123212

32133213
/* Default desired feerate is the feerate we set for them last. */
3214-
if (peer->channel->funder == LOCAL)
3214+
if (peer->channel->opener == LOCAL)
32153215
peer->desired_feerate = channel_feerate(peer->channel, REMOTE);
32163216

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

channeld/commit_tx.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
8585
const struct bitcoin_txid *funding_txid,
8686
unsigned int funding_txout,
8787
struct amount_sat funding,
88-
enum side funder,
88+
enum side opener,
8989
u16 to_self_delay,
9090
const struct keyset *keyset,
9191
u32 feerate_per_kw,
@@ -131,7 +131,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
131131
* 3. Subtract this base fee from the funder (either `to_local` or
132132
* `to_remote`), with a floor of 0 (see [Fee Payment](#fee-payment)).
133133
*/
134-
try_subtract_fee(funder, side, base_fee, &self_pay, &other_pay);
134+
try_subtract_fee(opener, side, base_fee, &self_pay, &other_pay);
135135

136136
#ifdef PRINT_ACTUAL_FEE
137137
{

channeld/commit_tx.h

+2-2
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.
@@ -47,7 +47,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
4747
const struct bitcoin_txid *funding_txid,
4848
unsigned int funding_txout,
4949
struct amount_sat funding,
50-
enum side funder,
50+
enum side opener,
5151
u16 to_self_delay,
5252
const struct keyset *keyset,
5353
u32 feerate_per_kw,

channeld/full_channel.c

+33-33
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct channel *new_full_channel(const tal_t *ctx,
101101
const struct pubkey *local_funding_pubkey,
102102
const struct pubkey *remote_funding_pubkey,
103103
bool option_static_remotekey,
104-
enum side funder)
104+
enum side opener)
105105
{
106106
struct channel *channel = new_initial_channel(ctx,
107107
funding_txid,
@@ -116,7 +116,7 @@ struct channel *new_full_channel(const tal_t *ctx,
116116
local_funding_pubkey,
117117
remote_funding_pubkey,
118118
option_static_remotekey,
119-
funder);
119+
opener);
120120

121121
if (channel) {
122122
channel->htlcs = tal(channel, struct htlc_map);
@@ -295,7 +295,7 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx,
295295
txs = tal_arr(ctx, struct bitcoin_tx *, 1);
296296
txs[0] = commit_tx(
297297
ctx, &channel->funding_txid, channel->funding_txout,
298-
channel->funding, channel->funder,
298+
channel->funding, channel->opener,
299299
channel->config[!side].to_self_delay, &keyset,
300300
channel_feerate(channel, side),
301301
channel->config[side].dust_limit, channel->view[side].owed[side],
@@ -384,8 +384,8 @@ static struct amount_sat fee_for_htlcs(const struct channel *channel,
384384
}
385385

386386
/*
387-
* There is a corner case where the funder can spend so much that the
388-
* non-funder can't add any non-dust HTLCs (since the funder would
387+
* There is a corner case where the opener can spend so much that the
388+
* non-opener can't add any non-dust HTLCs (since the opener would
389389
* have to pay the additional fee, but it can't afford to). This
390390
* leads to the channel starving at the feast! This was reported by
391391
* ACINQ's @t-bast
@@ -394,7 +394,7 @@ static struct amount_sat fee_for_htlcs(const struct channel *channel,
394394
* (https://github.com/ElementsProject/lightning/pull/3498).
395395
*
396396
* To mostly avoid this situation, at least from our side, we apply an
397-
* additional constraint when we're funder trying to add an HTLC: make
397+
* additional constraint when we're opener trying to add an HTLC: make
398398
* sure we can afford one more HTLC, even if fees increase by 100%.
399399
*
400400
* We could do this for the peer, as well, by rejecting their HTLC
@@ -408,7 +408,7 @@ static struct amount_sat fee_for_htlcs(const struct channel *channel,
408408
* This mitigation will become BOLT #2 standard by:
409409
* https://github.com/lightningnetwork/lightning-rfc/issues/740
410410
*/
411-
static bool local_funder_has_fee_headroom(const struct channel *channel,
411+
static bool local_opener_has_fee_headroom(const struct channel *channel,
412412
struct amount_msat remainder,
413413
const struct htlc **committed,
414414
const struct htlc **adding,
@@ -418,7 +418,7 @@ static bool local_funder_has_fee_headroom(const struct channel *channel,
418418
size_t untrimmed;
419419
struct amount_sat fee;
420420

421-
assert(channel->funder == LOCAL);
421+
assert(channel->opener == LOCAL);
422422

423423
/* How many untrimmed at current feerate? Increasing feerate can
424424
* only *reduce* this number, so use current feerate here! */
@@ -540,7 +540,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
540540
*/
541541
/* Also we should not add more htlc's than sender or recipient
542542
* configured. This mitigates attacks in which a peer can force the
543-
* funder of the channel to pay unnecessary onchain fees during a fee
543+
* opener of the channel to pay unnecessary onchain fees during a fee
544544
* spike with large commitment transactions.
545545
*/
546546
min_concurrent_htlcs = channel->config[recipient].max_accepted_htlcs;
@@ -614,7 +614,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
614614
&remainder))
615615
return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED;
616616

617-
if (channel->funder == sender) {
617+
if (channel->opener== sender) {
618618
if (amount_msat_less_sat(remainder, fee)) {
619619
status_debug("Cannot afford fee %s with %s above reserve",
620620
type_to_string(tmpctx, struct amount_sat,
@@ -625,7 +625,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
625625
}
626626

627627
if (sender == LOCAL
628-
&& !local_funder_has_fee_headroom(channel,
628+
&& !local_opener_has_fee_headroom(channel,
629629
remainder,
630630
committed,
631631
adding,
@@ -634,12 +634,12 @@ static enum channel_add_err add_htlc(struct channel *channel,
634634
}
635635
}
636636

637-
/* Try not to add a payment which will take funder into fees
637+
/* Try not to add a payment which will take opener into fees
638638
* on either our side or theirs. */
639639
if (sender == LOCAL) {
640640
if (!get_room_above_reserve(channel, view,
641641
adding, removing,
642-
channel->funder,
642+
channel->opener,
643643
&remainder))
644644
return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED;
645645
/* Should be able to afford both their own commit tx
@@ -649,7 +649,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
649649
committed,
650650
adding,
651651
removing,
652-
channel->funder);
652+
channel->opener);
653653
/* set fee output pointer if given */
654654
if (htlc_fee && amount_sat_greater(fee, *htlc_fee))
655655
*htlc_fee = fee;
@@ -667,7 +667,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
667667
committed,
668668
adding,
669669
removing,
670-
!channel->funder);
670+
!channel->opener);
671671
/* set fee output pointer if given */
672672
if (htlc_fee && amount_sat_greater(fee, *htlc_fee))
673673
*htlc_fee = fee;
@@ -970,7 +970,7 @@ u32 approx_max_feerate(const struct channel *channel)
970970
struct amount_sat avail;
971971
const struct htlc **committed, **adding, **removing;
972972

973-
gather_htlcs(tmpctx, channel, !channel->funder,
973+
gather_htlcs(tmpctx, channel, !channel->opener,
974974
&committed, &removing, &adding);
975975

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

10021002
/* We should never go below reserve. */
10031003
if (!amount_sat_sub(&avail,
1004-
amount_msat_to_sat_round_down(channel->view[!channel->funder].owed[channel->funder]),
1005-
channel->config[!channel->funder].channel_reserve))
1004+
amount_msat_to_sat_round_down(channel->view[!channel->opener].owed[channel->opener]),
1005+
channel->config[!channel->opener].channel_reserve))
10061006
avail = AMOUNT_SAT(0);
10071007

10081008
return avail.satoshis / weight * 1000; /* Raw: once-off reverse feerate*/
10091009
}
10101010

1011-
bool can_funder_afford_feerate(const struct channel *channel, u32 feerate_per_kw)
1011+
bool can_opener_afford_feerate(const struct channel *channel, u32 feerate_per_kw)
10121012
{
10131013
struct amount_sat needed, fee;
1014-
struct amount_sat dust_limit = channel->config[!channel->funder].dust_limit;
1014+
struct amount_sat dust_limit = channel->config[!channel->opener].dust_limit;
10151015
size_t untrimmed;
10161016
const struct htlc **committed, **adding, **removing;
1017-
gather_htlcs(tmpctx, channel, !channel->funder,
1017+
gather_htlcs(tmpctx, channel, !channel->opener,
10181018
&committed, &removing, &adding);
10191019

10201020
untrimmed = commit_tx_num_untrimmed(committed, feerate_per_kw, dust_limit,
1021-
!channel->funder)
1021+
!channel->opener)
10221022
+ commit_tx_num_untrimmed(adding, feerate_per_kw, dust_limit,
1023-
!channel->funder)
1023+
!channel->opener)
10241024
- commit_tx_num_untrimmed(removing, feerate_per_kw, dust_limit,
1025-
!channel->funder);
1025+
!channel->opener);
10261026

10271027
fee = commit_tx_base_fee(feerate_per_kw, untrimmed);
10281028

@@ -1032,38 +1032,38 @@ bool can_funder_afford_feerate(const struct channel *channel, u32 feerate_per_kw
10321032
* node's current commitment transaction:
10331033
* - SHOULD fail the channel
10341034
*/
1035-
/* Note: sender == funder */
1035+
/* Note: sender == opener */
10361036

10371037
/* How much does it think it has? Must be >= reserve + fee */
10381038
if (!amount_sat_add(&needed, fee,
1039-
channel->config[!channel->funder].channel_reserve))
1039+
channel->config[!channel->opener].channel_reserve))
10401040
status_failed(STATUS_FAIL_INTERNAL_ERROR,
10411041
"Cannot add fee %s and reserve %s",
10421042
type_to_string(tmpctx, struct amount_sat,
10431043
&fee),
10441044
type_to_string(tmpctx, struct amount_sat,
1045-
&channel->config[!channel->funder].channel_reserve));
1045+
&channel->config[!channel->opener].channel_reserve));
10461046

10471047
status_debug("We need %s at feerate %u for %zu untrimmed htlcs: we have %s/%s",
10481048
type_to_string(tmpctx, struct amount_sat, &needed),
10491049
feerate_per_kw, untrimmed,
10501050
type_to_string(tmpctx, struct amount_msat,
1051-
&channel->view[LOCAL].owed[channel->funder]),
1051+
&channel->view[LOCAL].owed[channel->opener]),
10521052
type_to_string(tmpctx, struct amount_msat,
1053-
&channel->view[REMOTE].owed[channel->funder]));
1054-
return amount_msat_greater_eq_sat(channel->view[!channel->funder].owed[channel->funder],
1053+
&channel->view[REMOTE].owed[channel->opener]));
1054+
return amount_msat_greater_eq_sat(channel->view[!channel->opener].owed[channel->opener],
10551055
needed);
10561056
}
10571057

10581058
bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw)
10591059
{
1060-
if (!can_funder_afford_feerate(channel, feerate_per_kw))
1060+
if (!can_opener_afford_feerate(channel, feerate_per_kw))
10611061
return false;
10621062

10631063
status_debug("Setting %s feerate to %u",
1064-
side_to_str(!channel->funder), feerate_per_kw);
1064+
side_to_str(!channel->opener), feerate_per_kw);
10651065

1066-
start_fee_update(channel->fee_states, channel->funder, feerate_per_kw);
1066+
start_fee_update(channel->fee_states, channel->opener, feerate_per_kw);
10671067
return true;
10681068
}
10691069

0 commit comments

Comments
 (0)