diff --git a/channeld/channel_wire.csv b/channeld/channel_wire.csv index 3f36ac80e..cf87f8a1a 100644 --- a/channeld/channel_wire.csv +++ b/channeld/channel_wire.csv @@ -24,7 +24,7 @@ msgdata,channel_init,remote_fundingkey,pubkey, msgdata,channel_init,remote_basepoints,basepoints, msgdata,channel_init,remote_per_commit,pubkey, msgdata,channel_init,old_remote_per_commit,pubkey, -msgdata,channel_init,funder,enum side, +msgdata,channel_init,opener,enum side, msgdata,channel_init,fee_base,u32, msgdata,channel_init,fee_proportional,u32, msgdata,channel_init,local_msatoshi,amount_msat, diff --git a/channeld/channeld.c b/channeld/channeld.c index 24b037fd5..ce1aacbfc 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -669,10 +669,10 @@ static void handle_peer_feechange(struct peer *peer, const u8 *msg) * - if the sender is not responsible for paying the Bitcoin fee: * - MUST fail the channel. */ - if (peer->channel->funder != REMOTE) + if (peer->channel->opener != REMOTE) peer_failed(peer->pps, &peer->channel_id, - "update_fee from non-funder?"); + "update_fee from non-opener?"); status_debug("update_fee %u, range %u-%u", feerate, peer->feerate_min, peer->feerate_max); @@ -975,7 +975,7 @@ static void send_commit(struct peer *peer) } /* If we wanted to update fees, do it now. */ - if (peer->channel->funder == LOCAL) { + if (peer->channel->opener == LOCAL) { u32 feerate, max = approx_max_feerate(peer->channel); feerate = peer->desired_feerate; @@ -1240,11 +1240,11 @@ static void handle_peer_commit_sig(struct peer *peer, const u8 *msg) } /* We were supposed to check this was affordable as we go. */ - if (peer->channel->funder == REMOTE) { + if (peer->channel->opener == REMOTE) { status_debug("Feerates are %u/%u", channel_feerate(peer->channel, LOCAL), channel_feerate(peer->channel, REMOTE)); - assert(can_funder_afford_feerate(peer->channel, + assert(can_opener_afford_feerate(peer->channel, channel_feerate(peer->channel, LOCAL))); } @@ -1432,7 +1432,7 @@ static void handle_peer_revoke_and_ack(struct peer *peer, const u8 *msg) peer->old_remote_per_commit = peer->remote_per_commit; peer->remote_per_commit = next_per_commit; status_debug("revoke_and_ack %s: remote_per_commit = %s, old_remote_per_commit = %s", - side_to_str(peer->channel->funder), + side_to_str(peer->channel->opener), type_to_string(tmpctx, struct pubkey, &peer->remote_per_commit), type_to_string(tmpctx, struct pubkey, @@ -2107,7 +2107,7 @@ static void resend_commitment(struct peer *peer, const struct changed_htlc *last } /* Make sure they have the correct fee. */ - if (peer->channel->funder == LOCAL) { + if (peer->channel->opener == LOCAL) { msg = towire_update_fee(NULL, &peer->channel_id, channel_feerate(peer->channel, REMOTE)); sync_crypto_write(peer->pps, take(msg)); @@ -2812,7 +2812,7 @@ static void handle_feerates(struct peer *peer, const u8 *inmsg) * sufficient (by a significant margin) for timely processing of the * commitment transaction. */ - if (peer->channel->funder == LOCAL) { + if (peer->channel->opener == LOCAL) { peer->desired_feerate = feerate; /* Don't do this for the first feerate, wait until something else * happens. LND seems to get upset in some cases otherwise: @@ -3067,7 +3067,7 @@ static void init_channel(struct peer *peer) struct pubkey funding_pubkey[NUM_SIDES]; struct channel_config conf[NUM_SIDES]; struct bitcoin_txid funding_txid; - enum side funder; + enum side opener; struct existing_htlc **htlcs; bool reconnected; u8 *funding_signed; @@ -3102,7 +3102,7 @@ static void init_channel(struct peer *peer) &points[REMOTE], &peer->remote_per_commit, &peer->old_remote_per_commit, - &funder, + &opener, &peer->fee_base, &peer->fee_per_satoshi, &local_msat, @@ -3148,7 +3148,7 @@ static void init_channel(struct peer *peer) " next_idx_remote = %"PRIu64 " revocations_received = %"PRIu64 " feerates %s range %u-%u", - side_to_str(funder), + side_to_str(opener), type_to_string(tmpctx, struct pubkey, &peer->remote_per_commit), type_to_string(tmpctx, struct pubkey, @@ -3197,7 +3197,7 @@ static void init_channel(struct peer *peer) &funding_pubkey[LOCAL], &funding_pubkey[REMOTE], option_static_remotekey, - funder); + opener); if (!channel_force_htlcs(peer->channel, cast_const2(const struct existing_htlc **, htlcs))) @@ -3211,7 +3211,7 @@ static void init_channel(struct peer *peer) &peer->node_ids[REMOTE]); /* Default desired feerate is the feerate we set for them last. */ - if (peer->channel->funder == LOCAL) + if (peer->channel->opener == LOCAL) peer->desired_feerate = channel_feerate(peer->channel, REMOTE); /* from now we need keep watch over WIRE_CHANNEL_FUNDING_DEPTH */ diff --git a/channeld/commit_tx.c b/channeld/commit_tx.c index 44be92c56..bd75f411d 100644 --- a/channeld/commit_tx.c +++ b/channeld/commit_tx.c @@ -85,7 +85,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx, const struct bitcoin_txid *funding_txid, unsigned int funding_txout, struct amount_sat funding, - enum side funder, + enum side opener, u16 to_self_delay, const struct keyset *keyset, u32 feerate_per_kw, @@ -131,7 +131,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx, * 3. Subtract this base fee from the funder (either `to_local` or * `to_remote`), with a floor of 0 (see [Fee Payment](#fee-payment)). */ - try_subtract_fee(funder, side, base_fee, &self_pay, &other_pay); + try_subtract_fee(opener, side, base_fee, &self_pay, &other_pay); #ifdef PRINT_ACTUAL_FEE { diff --git a/channeld/commit_tx.h b/channeld/commit_tx.h index 6b01208c5..56fc6c765 100644 --- a/channeld/commit_tx.h +++ b/channeld/commit_tx.h @@ -28,7 +28,7 @@ size_t commit_tx_num_untrimmed(const struct htlc **htlcs, * commit_tx: create (unsigned) commitment tx to spend the funding tx output * @ctx: context to allocate transaction and @htlc_map from. * @funding_txid, @funding_out, @funding: funding outpoint. - * @funder: is the LOCAL or REMOTE paying the fee? + * @opener: is the LOCAL or REMOTE paying the fee? * @keyset: keys derived for this commit tx. * @feerate_per_kw: feerate to use * @dust_limit: dust limit below which to trim outputs. @@ -47,7 +47,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx, const struct bitcoin_txid *funding_txid, unsigned int funding_txout, struct amount_sat funding, - enum side funder, + enum side opener, u16 to_self_delay, const struct keyset *keyset, u32 feerate_per_kw, diff --git a/channeld/full_channel.c b/channeld/full_channel.c index fe8cf2b2f..7c718c878 100644 --- a/channeld/full_channel.c +++ b/channeld/full_channel.c @@ -101,7 +101,7 @@ struct channel *new_full_channel(const tal_t *ctx, const struct pubkey *local_funding_pubkey, const struct pubkey *remote_funding_pubkey, bool option_static_remotekey, - enum side funder) + enum side opener) { struct channel *channel = new_initial_channel(ctx, funding_txid, @@ -116,7 +116,7 @@ struct channel *new_full_channel(const tal_t *ctx, local_funding_pubkey, remote_funding_pubkey, option_static_remotekey, - funder); + opener); if (channel) { channel->htlcs = tal(channel, struct htlc_map); @@ -295,7 +295,7 @@ struct bitcoin_tx **channel_txs(const tal_t *ctx, txs = tal_arr(ctx, struct bitcoin_tx *, 1); txs[0] = commit_tx( ctx, &channel->funding_txid, channel->funding_txout, - channel->funding, channel->funder, + channel->funding, channel->opener, channel->config[!side].to_self_delay, &keyset, channel_feerate(channel, side), 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, } /* - * There is a corner case where the funder can spend so much that the - * non-funder can't add any non-dust HTLCs (since the funder would + * There is a corner case where the opener can spend so much that the + * non-opener can't add any non-dust HTLCs (since the opener would * have to pay the additional fee, but it can't afford to). This * leads to the channel starving at the feast! This was reported by * ACINQ's @t-bast @@ -394,7 +394,7 @@ static struct amount_sat fee_for_htlcs(const struct channel *channel, * (https://github.com/ElementsProject/lightning/pull/3498). * * To mostly avoid this situation, at least from our side, we apply an - * additional constraint when we're funder trying to add an HTLC: make + * additional constraint when we're opener trying to add an HTLC: make * sure we can afford one more HTLC, even if fees increase by 100%. * * 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, * This mitigation will become BOLT #2 standard by: * https://github.com/lightningnetwork/lightning-rfc/issues/740 */ -static bool local_funder_has_fee_headroom(const struct channel *channel, +static bool local_opener_has_fee_headroom(const struct channel *channel, struct amount_msat remainder, const struct htlc **committed, const struct htlc **adding, @@ -418,7 +418,7 @@ static bool local_funder_has_fee_headroom(const struct channel *channel, size_t untrimmed; struct amount_sat fee; - assert(channel->funder == LOCAL); + assert(channel->opener == LOCAL); /* How many untrimmed at current feerate? Increasing feerate can * only *reduce* this number, so use current feerate here! */ @@ -540,7 +540,7 @@ static enum channel_add_err add_htlc(struct channel *channel, */ /* Also we should not add more htlc's than sender or recipient * configured. This mitigates attacks in which a peer can force the - * funder of the channel to pay unnecessary onchain fees during a fee + * opener of the channel to pay unnecessary onchain fees during a fee * spike with large commitment transactions. */ min_concurrent_htlcs = channel->config[recipient].max_accepted_htlcs; @@ -614,7 +614,7 @@ static enum channel_add_err add_htlc(struct channel *channel, &remainder)) return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED; - if (channel->funder == sender) { + if (channel->opener== sender) { if (amount_msat_less_sat(remainder, fee)) { status_debug("Cannot afford fee %s with %s above reserve", type_to_string(tmpctx, struct amount_sat, @@ -625,7 +625,7 @@ static enum channel_add_err add_htlc(struct channel *channel, } if (sender == LOCAL - && !local_funder_has_fee_headroom(channel, + && !local_opener_has_fee_headroom(channel, remainder, committed, adding, @@ -634,12 +634,12 @@ static enum channel_add_err add_htlc(struct channel *channel, } } - /* Try not to add a payment which will take funder into fees + /* Try not to add a payment which will take opener into fees * on either our side or theirs. */ if (sender == LOCAL) { if (!get_room_above_reserve(channel, view, adding, removing, - channel->funder, + channel->opener, &remainder)) return CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED; /* Should be able to afford both their own commit tx @@ -649,7 +649,7 @@ static enum channel_add_err add_htlc(struct channel *channel, committed, adding, removing, - channel->funder); + channel->opener); /* set fee output pointer if given */ if (htlc_fee && amount_sat_greater(fee, *htlc_fee)) *htlc_fee = fee; @@ -667,7 +667,7 @@ static enum channel_add_err add_htlc(struct channel *channel, committed, adding, removing, - !channel->funder); + !channel->opener); /* set fee output pointer if given */ if (htlc_fee && amount_sat_greater(fee, *htlc_fee)) *htlc_fee = fee; @@ -970,7 +970,7 @@ u32 approx_max_feerate(const struct channel *channel) struct amount_sat avail; const struct htlc **committed, **adding, **removing; - gather_htlcs(tmpctx, channel, !channel->funder, + gather_htlcs(tmpctx, channel, !channel->opener, &committed, &removing, &adding); /* Assume none are trimmed; this gives lower bound on feerate. */ @@ -1001,28 +1001,28 @@ u32 approx_max_feerate(const struct channel *channel) /* We should never go below reserve. */ if (!amount_sat_sub(&avail, - amount_msat_to_sat_round_down(channel->view[!channel->funder].owed[channel->funder]), - channel->config[!channel->funder].channel_reserve)) + amount_msat_to_sat_round_down(channel->view[!channel->opener].owed[channel->opener]), + channel->config[!channel->opener].channel_reserve)) avail = AMOUNT_SAT(0); return avail.satoshis / weight * 1000; /* Raw: once-off reverse feerate*/ } -bool can_funder_afford_feerate(const struct channel *channel, u32 feerate_per_kw) +bool can_opener_afford_feerate(const struct channel *channel, u32 feerate_per_kw) { struct amount_sat needed, fee; - struct amount_sat dust_limit = channel->config[!channel->funder].dust_limit; + struct amount_sat dust_limit = channel->config[!channel->opener].dust_limit; size_t untrimmed; const struct htlc **committed, **adding, **removing; - gather_htlcs(tmpctx, channel, !channel->funder, + gather_htlcs(tmpctx, channel, !channel->opener, &committed, &removing, &adding); untrimmed = commit_tx_num_untrimmed(committed, feerate_per_kw, dust_limit, - !channel->funder) + !channel->opener) + commit_tx_num_untrimmed(adding, feerate_per_kw, dust_limit, - !channel->funder) + !channel->opener) - commit_tx_num_untrimmed(removing, feerate_per_kw, dust_limit, - !channel->funder); + !channel->opener); fee = commit_tx_base_fee(feerate_per_kw, untrimmed); @@ -1032,38 +1032,38 @@ bool can_funder_afford_feerate(const struct channel *channel, u32 feerate_per_kw * node's current commitment transaction: * - SHOULD fail the channel */ - /* Note: sender == funder */ + /* Note: sender == opener */ /* How much does it think it has? Must be >= reserve + fee */ if (!amount_sat_add(&needed, fee, - channel->config[!channel->funder].channel_reserve)) + channel->config[!channel->opener].channel_reserve)) status_failed(STATUS_FAIL_INTERNAL_ERROR, "Cannot add fee %s and reserve %s", type_to_string(tmpctx, struct amount_sat, &fee), type_to_string(tmpctx, struct amount_sat, - &channel->config[!channel->funder].channel_reserve)); + &channel->config[!channel->opener].channel_reserve)); status_debug("We need %s at feerate %u for %zu untrimmed htlcs: we have %s/%s", type_to_string(tmpctx, struct amount_sat, &needed), feerate_per_kw, untrimmed, type_to_string(tmpctx, struct amount_msat, - &channel->view[LOCAL].owed[channel->funder]), + &channel->view[LOCAL].owed[channel->opener]), type_to_string(tmpctx, struct amount_msat, - &channel->view[REMOTE].owed[channel->funder])); - return amount_msat_greater_eq_sat(channel->view[!channel->funder].owed[channel->funder], + &channel->view[REMOTE].owed[channel->opener])); + return amount_msat_greater_eq_sat(channel->view[!channel->opener].owed[channel->opener], needed); } bool channel_update_feerate(struct channel *channel, u32 feerate_per_kw) { - if (!can_funder_afford_feerate(channel, feerate_per_kw)) + if (!can_opener_afford_feerate(channel, feerate_per_kw)) return false; status_debug("Setting %s feerate to %u", - side_to_str(!channel->funder), feerate_per_kw); + side_to_str(!channel->opener), feerate_per_kw); - start_fee_update(channel->fee_states, channel->funder, feerate_per_kw); + start_fee_update(channel->fee_states, channel->opener, feerate_per_kw); return true; } diff --git a/channeld/full_channel.h b/channeld/full_channel.h index e7fa565c7..7d618ec9c 100644 --- a/channeld/full_channel.h +++ b/channeld/full_channel.h @@ -25,7 +25,7 @@ struct existing_htlc; * @local_fundingkey: local funding key * @remote_fundingkey: remote funding key * @option_static_remotekey: use `option_static_remotekey`. - * @funder: which side initiated it. + * @opener: which side initiated it. * * Returns state, or NULL if malformed. */ @@ -43,7 +43,7 @@ struct channel *new_full_channel(const tal_t *ctx, const struct pubkey *local_funding_pubkey, const struct pubkey *remote_funding_pubkey, bool option_static_remotekey, - enum side funder); + enum side opener); /** * channel_txs: Get the current commitment and htlc txs for the channel. @@ -151,7 +151,7 @@ enum channel_remove_err channel_fulfill_htlc(struct channel *channel, struct htlc **htlcp); /** - * approx_max_feerate: what's the max funder could raise fee rate to? + * approx_max_feerate: what's the max opener could raise fee rate to? * @channel: The channel state * * This is not exact! To check if their offer is valid, try @@ -160,14 +160,14 @@ enum channel_remove_err channel_fulfill_htlc(struct channel *channel, u32 approx_max_feerate(const struct channel *channel); /** - * can_funder_afford_feerate: could the funder pay the fee? + * can_opener_afford_feerate: could the opener pay the fee? * @channel: The channel state * @feerate: The feerate in satoshi per 1000 bytes. */ -bool can_funder_afford_feerate(const struct channel *channel, u32 feerate); +bool can_opener_afford_feerate(const struct channel *channel, u32 feerate); /** - * channel_update_feerate: Change fee rate on non-funder side. + * channel_update_feerate: Change fee rate on non-opener side. * @channel: The channel * @feerate_per_kw: fee in satoshi per 1000 bytes. * diff --git a/channeld/test/run-commit_tx.c b/channeld/test/run-commit_tx.c index df054f090..48c3945b0 100644 --- a/channeld/test/run-commit_tx.c +++ b/channeld/test/run-commit_tx.c @@ -938,7 +938,7 @@ int main(void) tx = newtx; } while (tx->wtx->num_outputs > 1); - /* Now make sure we cover case where funder can't afford the fee; + /* Now make sure we cover case where opener can't afford the fee; * its output cannot go negative! */ for (;;) { struct amount_sat base_fee @@ -959,7 +959,7 @@ int main(void) assert(feerate_per_kw == 9651936); printf("\n" - "name: commitment tx with fee greater than funder amount\n" + "name: commitment tx with fee greater than opener amount\n" "to_local_msat: %"PRIu64"\n" "to_remote_msat: %"PRIu64"\n" "local_feerate_per_kw: %u\n", diff --git a/channeld/test/run-full_channel.c b/channeld/test/run-full_channel.c index 4a4c2f8b2..2fac4d079 100644 --- a/channeld/test/run-full_channel.c +++ b/channeld/test/run-full_channel.c @@ -314,7 +314,7 @@ static void update_feerate(struct channel *channel, u32 feerate) ret = channel_update_feerate(channel, feerate); assert(ret); - if (channel->funder == LOCAL) { + if (channel->opener == LOCAL) { ret = channel_sending_commit(channel, NULL); assert(ret); ret = channel_rcvd_revoke_and_ack(channel, NULL); diff --git a/closingd/closing_wire.csv b/closingd/closing_wire.csv index c12620cdc..f2b0e3776 100644 --- a/closingd/closing_wire.csv +++ b/closingd/closing_wire.csv @@ -10,7 +10,7 @@ msgdata,closing_init,funding_txout,u16, msgdata,closing_init,funding_satoshi,amount_sat, msgdata,closing_init,local_fundingkey,pubkey, msgdata,closing_init,remote_fundingkey,pubkey, -msgdata,closing_init,funder,enum side, +msgdata,closing_init,opener,enum side, msgdata,closing_init,local_sat,amount_sat, msgdata,closing_init,remote_sat,amount_sat, msgdata,closing_init,our_dust_limit,amount_sat, diff --git a/closingd/closingd.c b/closingd/closingd.c index 578a3755a..505d968d3 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -40,7 +40,7 @@ static struct bitcoin_tx *close_tx(const tal_t *ctx, unsigned int funding_txout, struct amount_sat funding, const struct amount_sat out[NUM_SIDES], - enum side funder, + enum side opener, struct amount_sat fee, struct amount_sat dust_limit) { @@ -49,7 +49,7 @@ static struct bitcoin_tx *close_tx(const tal_t *ctx, out_minus_fee[LOCAL] = out[LOCAL]; out_minus_fee[REMOTE] = out[REMOTE]; - if (!amount_sat_sub(&out_minus_fee[funder], out[funder], fee)) + if (!amount_sat_sub(&out_minus_fee[opener], out[opener], fee)) peer_failed(pps, channel_id, "Funder cannot afford fee %s (%s and %s)", type_to_string(tmpctx, struct amount_sat, &fee), @@ -243,7 +243,7 @@ static void send_offer(struct per_peer_state *pps, unsigned int funding_txout, struct amount_sat funding, const struct amount_sat out[NUM_SIDES], - enum side funder, + enum side opener, struct amount_sat our_dust_limit, struct amount_sat fee_to_offer) { @@ -263,7 +263,7 @@ static void send_offer(struct per_peer_state *pps, funding_txout, funding, out, - funder, fee_to_offer, our_dust_limit); + opener, fee_to_offer, our_dust_limit); /* BOLT #3: * @@ -321,7 +321,7 @@ receive_offer(struct per_peer_state *pps, unsigned int funding_txout, struct amount_sat funding, const struct amount_sat out[NUM_SIDES], - enum side funder, + enum side opener, struct amount_sat our_dust_limit, struct amount_sat min_fee_to_accept, struct bitcoin_txid *closing_txid) @@ -372,7 +372,7 @@ receive_offer(struct per_peer_state *pps, funding_txid, funding_txout, funding, - out, funder, received_fee, our_dust_limit); + out, opener, received_fee, our_dust_limit); if (!check_tx_sig(tx, 0, NULL, funding_wscript, &funding_pubkey[REMOTE], &their_sig)) { @@ -380,7 +380,7 @@ receive_offer(struct per_peer_state *pps, struct bitcoin_tx *trimmed; struct amount_sat trimming_out[NUM_SIDES]; - if (funder == REMOTE) + if (opener == REMOTE) trimming_out[REMOTE] = received_fee; else trimming_out[REMOTE] = AMOUNT_SAT(0); @@ -402,7 +402,7 @@ receive_offer(struct per_peer_state *pps, funding_txout, funding, trimming_out, - funder, received_fee, our_dust_limit); + opener, received_fee, our_dust_limit); if (!trimmed || !check_tx_sig(trimmed, 0, NULL, funding_wscript, &funding_pubkey[REMOTE], &their_sig)) { @@ -603,7 +603,7 @@ int main(int argc, char *argv[]) struct amount_sat our_dust_limit; struct amount_sat min_fee_to_accept, commitment_fee, offer[NUM_SIDES]; struct feerange feerange; - enum side funder; + enum side opener; u8 *scriptpubkey[NUM_SIDES], *funding_wscript; u64 fee_negotiation_step; u8 fee_negotiation_step_unit; @@ -627,7 +627,7 @@ int main(int argc, char *argv[]) &funding, &funding_pubkey[LOCAL], &funding_pubkey[REMOTE], - &funder, + &opener, &out[LOCAL], &out[REMOTE], &our_dust_limit, @@ -692,13 +692,13 @@ int main(int argc, char *argv[]) * commitment transaction: * - SHOULD send a `closing_signed` message. */ - whose_turn = funder; + whose_turn = opener; for (size_t i = 0; i < 2; i++, whose_turn = !whose_turn) { if (whose_turn == LOCAL) { send_offer(pps, chainparams, &channel_id, funding_pubkey, scriptpubkey, &funding_txid, funding_txout, - funding, out, funder, + funding, out, opener, our_dust_limit, offer[LOCAL]); } else { @@ -718,7 +718,7 @@ int main(int argc, char *argv[]) funding_wscript, scriptpubkey, &funding_txid, funding_txout, funding, - out, funder, + out, opener, our_dust_limit, min_fee_to_accept, &closing_txid); @@ -728,8 +728,8 @@ int main(int argc, char *argv[]) /* Now we have first two points, we can init fee range. */ init_feerange(&feerange, commitment_fee, offer); - /* Apply (and check) funder offer now. */ - adjust_feerange(&feerange, offer[funder], funder); + /* Apply (and check) opener offer now. */ + adjust_feerange(&feerange, offer[opener], opener); /* Now any extra rounds required. */ while (!amount_sat_eq(offer[LOCAL], offer[REMOTE])) { @@ -747,7 +747,7 @@ int main(int argc, char *argv[]) send_offer(pps, chainparams, &channel_id, funding_pubkey, scriptpubkey, &funding_txid, funding_txout, - funding, out, funder, + funding, out, opener, our_dust_limit, offer[LOCAL]); } else { @@ -762,7 +762,7 @@ int main(int argc, char *argv[]) funding_wscript, scriptpubkey, &funding_txid, funding_txout, funding, - out, funder, + out, opener, our_dust_limit, min_fee_to_accept, &closing_txid); diff --git a/common/fee_states.c b/common/fee_states.c index b8cb60be1..591ac2132 100644 --- a/common/fee_states.c +++ b/common/fee_states.c @@ -6,24 +6,24 @@ /* If we're the finder, it's like an HTLC we added, if they are, it's like * a HTLC they added. */ -enum htlc_state first_fee_state(enum side funder) +enum htlc_state first_fee_state(enum side opener) { - if (funder == LOCAL) + if (opener == LOCAL) return SENT_ADD_HTLC; else return RCVD_ADD_HTLC; } -enum htlc_state last_fee_state(enum side funder) +enum htlc_state last_fee_state(enum side opener) { - if (funder == LOCAL) + if (opener == LOCAL) return SENT_ADD_ACK_REVOCATION; else return RCVD_ADD_ACK_REVOCATION; } struct fee_states *new_fee_states(const tal_t *ctx, - enum side funder, + enum side opener, const u32 *feerate_per_kw) { struct fee_states *fee_states = tal(ctx, struct fee_states); @@ -32,7 +32,7 @@ struct fee_states *new_fee_states(const tal_t *ctx, for (size_t i = 0; i < ARRAY_SIZE(fee_states->feerate); i++) fee_states->feerate[i] = NULL; if (feerate_per_kw) - fee_states->feerate[last_fee_state(funder)] + fee_states->feerate[last_fee_state(opener)] = tal_dup(fee_states, u32, feerate_per_kw); return fee_states; } @@ -54,12 +54,12 @@ struct fee_states *dup_fee_states(const tal_t *ctx, } u32 get_feerate(const struct fee_states *fee_states, - enum side funder, + enum side opener, enum side side) { /* The first non-NULL feerate committed to this side is current */ - for (enum htlc_state i = first_fee_state(funder); - i <= last_fee_state(funder); + for (enum htlc_state i = first_fee_state(opener); + i <= last_fee_state(opener); i++) { if (!fee_states->feerate[i]) continue; @@ -73,10 +73,10 @@ u32 get_feerate(const struct fee_states *fee_states, } void start_fee_update(struct fee_states *fee_states, - enum side funder, + enum side opener, u32 feerate_per_kw) { - enum htlc_state start = first_fee_state(funder); + enum htlc_state start = first_fee_state(opener); /* BOLT #2: * Unlike an HTLC, `update_fee` is never closed but simply replaced. @@ -135,11 +135,11 @@ void towire_fee_states(u8 **pptr, const struct fee_states *fee_states) } } -/* FIXME: we don't know funder inside fromwire_fee_states, so can't do +/* FIXME: we don't know opener inside fromwire_fee_states, so can't do * this there :( */ -bool fee_states_valid(const struct fee_states *fee_states, enum side funder) +bool fee_states_valid(const struct fee_states *fee_states, enum side opener) { - return fee_states->feerate[last_fee_state(funder)] != NULL; + return fee_states->feerate[last_fee_state(opener)] != NULL; } static const char *fmt_fee_states(const tal_t *ctx, diff --git a/common/fee_states.h b/common/fee_states.h index 606a057bd..5eb2029fe 100644 --- a/common/fee_states.h +++ b/common/fee_states.h @@ -18,11 +18,11 @@ struct fee_states { /** * new_fee_states: Initialize a fee_states structure as at open-of-channel. * @ctx: the tal ctx to allocate off - * @funder: which side funded the channel (and thus, proposes fee updates). + * @opener: which side opened the channel (and thus, proposes fee updates). * @feerate_per_kw: the initial feerate (if any). */ struct fee_states *new_fee_states(const tal_t *ctx, - enum side funder, + enum side opener, const u32 *feerate_per_kw); /** @@ -36,33 +36,33 @@ struct fee_states *dup_fee_states(const tal_t *ctx, /** * get_feerate: Get the current feerate * @fee_states: the fee state machine - * @funder: which side funded the channel (and thus, proposes fee updates). + * @opener: which side opened the channel (and thus, proposes fee updates). * @side: which side to get the feerate for */ u32 get_feerate(const struct fee_states *fee_states, - enum side funder, + enum side opener, enum side side); /** * first_fee_state: get the initial fee state. - * @funder: which side funded the channel (and thus, proposes fee updates). + * @opener: which side opened the channel (and thus, proposes fee updates). */ -enum htlc_state first_fee_state(enum side funder); +enum htlc_state first_fee_state(enum side opener); /** * last_fee_state: get the final fee state. - * @funder: which side funded the channel (and thus, proposes fee updates). + * @opener: which side opened the channel (and thus, proposes fee updates). */ -enum htlc_state last_fee_state(enum side funder); +enum htlc_state last_fee_state(enum side opener); /** * start_fee_update: feed a new fee update into state machine. * @fee_states: the fee state machine - * @funder: which side funded the channel (and thus, proposes fee updates). + * @opener: which side opened the channel (and thus, proposes fee updates). * @feerate_per_kw: the new feerate. */ void start_fee_update(struct fee_states *fee_states, - enum side funder, + enum side opener, u32 feerate_per_kw); /** @@ -82,7 +82,7 @@ struct fee_states *fromwire_fee_states(const tal_t *ctx, const u8 **cursor, size_t *max); /** - * Is this fee_state struct valid for this funding side? + * Is this fee_state struct valid for this side? */ -bool fee_states_valid(const struct fee_states *fee_states, enum side funder); +bool fee_states_valid(const struct fee_states *fee_states, enum side opener); #endif /* LIGHTNING_COMMON_FEE_STATES_H */ diff --git a/common/initial_channel.c b/common/initial_channel.c index 6074ee585..718b9a9cf 100644 --- a/common/initial_channel.c +++ b/common/initial_channel.c @@ -24,7 +24,7 @@ struct channel *new_initial_channel(const tal_t *ctx, const struct pubkey *local_funding_pubkey, const struct pubkey *remote_funding_pubkey, bool option_static_remotekey, - enum side funder) + enum side opener) { struct channel *channel = tal(ctx, struct channel); struct amount_msat remote_msatoshi; @@ -37,7 +37,7 @@ struct channel *new_initial_channel(const tal_t *ctx, channel->funding, local_msatoshi)) return tal_free(channel); - channel->funder = funder; + channel->opener = opener; channel->config[LOCAL] = *local; channel->config[REMOTE] = *remote; channel->funding_pubkey[LOCAL] = *local_funding_pubkey; @@ -58,8 +58,8 @@ struct channel *new_initial_channel(const tal_t *ctx, channel->basepoints[REMOTE] = *remote_basepoints; channel->commitment_number_obscurer - = commit_number_obscurer(&channel->basepoints[funder].payment, - &channel->basepoints[!funder].payment); + = commit_number_obscurer(&channel->basepoints[opener].payment, + &channel->basepoints[!opener].payment); channel->option_static_remotekey = option_static_remotekey; return channel; @@ -95,7 +95,7 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx, &channel->funding_txid, channel->funding_txout, channel->funding, - channel->funder, + channel->opener, /* They specify our to_self_delay and v.v. */ channel->config[!side].to_self_delay, &keyset, @@ -111,7 +111,7 @@ struct bitcoin_tx *initial_channel_tx(const tal_t *ctx, u32 channel_feerate(const struct channel *channel, enum side side) { - return get_feerate(channel->fee_states, channel->funder, side); + return get_feerate(channel->fee_states, channel->opener, side); } static char *fmt_channel_view(const tal_t *ctx, const struct channel_view *view) @@ -128,12 +128,12 @@ static char *fmt_channel_view(const tal_t *ctx, const struct channel_view *view) static char *fmt_channel(const tal_t *ctx, const struct channel *channel) { return tal_fmt(ctx, "{ funding=%s," - " funder=%s," + " opener=%s," " local=%s," " remote=%s }", type_to_string(tmpctx, struct amount_sat, &channel->funding), - side_to_str(channel->funder), + side_to_str(channel->opener), fmt_channel_view(ctx, &channel->view[LOCAL]), fmt_channel_view(ctx, &channel->view[REMOTE])); } diff --git a/common/initial_channel.h b/common/initial_channel.h index cf202127e..b68f7fe58 100644 --- a/common/initial_channel.h +++ b/common/initial_channel.h @@ -39,7 +39,7 @@ struct channel { u32 minimum_depth; /* Who is paying fees. */ - enum side funder; + enum side opener; /* Limits and settings on this channel. */ struct channel_config config[NUM_SIDES]; @@ -78,7 +78,7 @@ struct channel { * @remote_basepoints: remote basepoints. * @local_fundingkey: local funding key * @remote_fundingkey: remote funding key - * @funder: which side initiated it. + * @opener: which side initiated it. * * Returns channel, or NULL if malformed. */ @@ -96,7 +96,7 @@ struct channel *new_initial_channel(const tal_t *ctx, const struct pubkey *local_funding_pubkey, const struct pubkey *remote_funding_pubkey, bool option_static_remotekey, - enum side funder); + enum side opener); /** diff --git a/common/initial_commit_tx.c b/common/initial_commit_tx.c index f1a451cca..3c68ec6b0 100644 --- a/common/initial_commit_tx.c +++ b/common/initial_commit_tx.c @@ -30,22 +30,22 @@ u64 commit_number_obscurer(const struct pubkey *opener_payment_basepoint, return be64_to_cpu(obscurer); } -bool try_subtract_fee(enum side funder, enum side side, +bool try_subtract_fee(enum side opener, enum side side, struct amount_sat base_fee, struct amount_msat *self, struct amount_msat *other) { - struct amount_msat *funder_amount; + struct amount_msat *opener_amount; - if (funder == side) - funder_amount = self; + if (opener == side) + opener_amount = self; else - funder_amount = other; + opener_amount = other; - if (amount_msat_sub_sat(funder_amount, *funder_amount, base_fee)) + if (amount_msat_sub_sat(opener_amount, *opener_amount, base_fee)) return true; - *funder_amount = AMOUNT_MSAT(0); + *opener_amount = AMOUNT_MSAT(0); return false; } @@ -62,7 +62,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx, const struct bitcoin_txid *funding_txid, unsigned int funding_txout, struct amount_sat funding, - enum side funder, + enum side opener, u16 to_self_delay, const struct keyset *keyset, u32 feerate_per_kw, @@ -104,7 +104,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx, * 3. Subtract this base fee from the funder (either `to_local` or * `to_remote`), with a floor of 0 (see [Fee Payment](#fee-payment)). */ - if (!try_subtract_fee(funder, side, base_fee, &self_pay, &other_pay)) { + if (!try_subtract_fee(opener, side, base_fee, &self_pay, &other_pay)) { /* BOLT #2: * * The receiving node MUST fail the channel if: diff --git a/common/initial_commit_tx.h b/common/initial_commit_tx.h index 9e5e3dd3b..1e26e6842 100644 --- a/common/initial_commit_tx.h +++ b/common/initial_commit_tx.h @@ -76,7 +76,7 @@ static inline struct amount_sat commit_tx_base_fee(u32 feerate_per_kw, * initial_commit_tx: create (unsigned) commitment tx to spend the funding tx output * @ctx: context to allocate transaction and @htlc_map from. * @funding_txid, @funding_out, @funding: funding outpoint. - * @funder: is the LOCAL or REMOTE paying the fee? + * @opener: is the LOCAL or REMOTE paying the fee? * @keyset: keys derived for this commit tx. * @feerate_per_kw: feerate to use * @dust_limit: dust limit below which to trim outputs. @@ -95,7 +95,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx, const struct bitcoin_txid *funding_txid, unsigned int funding_txout, struct amount_sat funding, - enum side funder, + enum side opener, u16 to_self_delay, const struct keyset *keyset, u32 feerate_per_kw, @@ -107,8 +107,8 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx, enum side side, char** err_reason); -/* try_subtract_fee - take away this fee from the funder (and return true), or all if insufficient (and return false). */ -bool try_subtract_fee(enum side funder, enum side side, +/* try_subtract_fee - take away this fee from the opener (and return true), or all if insufficient (and return false). */ +bool try_subtract_fee(enum side opener, enum side side, struct amount_sat base_fee, struct amount_msat *self, struct amount_msat *other); diff --git a/doc/lightning-fundchannel_cancel.7 b/doc/lightning-fundchannel_cancel.7 index feb9e12d4..f068a790f 100644 --- a/doc/lightning-fundchannel_cancel.7 +++ b/doc/lightning-fundchannel_cancel.7 @@ -7,7 +7,7 @@ lightning-fundchannel_cancel - Command for completing channel establishment .SH DESCRIPTION -\fBfundchannel_cancel\fR is a lower level RPC command\. It allows channel funder +\fBfundchannel_cancel\fR is a lower level RPC command\. It allows channel opener to cancel a channel before funding broadcast with a connected peer\. diff --git a/doc/lightning-fundchannel_cancel.7.md b/doc/lightning-fundchannel_cancel.7.md index 70e821e85..068b247a1 100644 --- a/doc/lightning-fundchannel_cancel.7.md +++ b/doc/lightning-fundchannel_cancel.7.md @@ -9,7 +9,7 @@ SYNOPSIS DESCRIPTION ----------- -`fundchannel_cancel` is a lower level RPC command. It allows channel funder +`fundchannel_cancel` is a lower level RPC command. It allows channel opener to cancel a channel before funding broadcast with a connected peer. *id* is the node id of the remote peer with which to cancel. diff --git a/lightningd/channel.c b/lightningd/channel.c index 94687ea0d..33dcb13d0 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -145,7 +145,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, /* NULL or stolen */ struct wallet_shachain *their_shachain, enum channel_state state, - enum side funder, + enum side opener, /* NULL or stolen */ struct log *log, const char *transient_billboard TAKES, @@ -204,7 +204,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, shachain_init(&channel->their_shachain.chain); } channel->state = state; - channel->funder = funder; + channel->opener = opener; channel->owner = NULL; memset(&channel->billboard, 0, sizeof(channel->billboard)); channel->billboard.transient = tal_strdup(channel, transient_billboard); @@ -427,7 +427,7 @@ void channel_fail_forget(struct channel *channel, const char *fmt, ...) char *why; struct channel_id cid; - assert(channel->funder == REMOTE && + assert(channel->opener == REMOTE && channel->state == CHANNELD_AWAITING_LOCKIN); va_start(ap, fmt); why = tal_vfmt(tmpctx, fmt, ap); diff --git a/lightningd/channel.h b/lightningd/channel.h index f7f5ab7bc..9fc5c432f 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -34,7 +34,7 @@ struct channel { enum channel_state state; /* Which side offered channel? */ - enum side funder; + enum side opener; /* Is there a single subdaemon responsible for us? */ struct subd *owner; @@ -135,7 +135,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, /* NULL or stolen */ struct wallet_shachain *their_shachain STEALS, enum channel_state state, - enum side funder, + enum side opener, /* NULL or stolen */ struct log *log STEALS, const char *transient_billboard TAKES, diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 9fba5eb7e..6d0f7dbaa 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -481,7 +481,7 @@ void peer_start_channeld(struct channel *channel, &channel->channel_info.theirbase, &channel->channel_info.remote_per_commit, &channel->channel_info.old_remote_per_commit, - channel->funder, + channel->opener, channel->feerate_base, channel->feerate_ppm, channel->our_msat, @@ -523,7 +523,7 @@ void peer_start_channeld(struct channel *channel, subd_send_msg(channel->owner, take(initmsg)); /* On restart, feerate might not be what we expect: adjust now. */ - if (channel->funder == LOCAL) + if (channel->opener == LOCAL) try_update_feerates(ld, channel); } @@ -583,7 +583,7 @@ is_fundee_should_forget(struct lightningd *ld, */ /* Only applies if we are fundee. */ - if (channel->funder == LOCAL) + if (channel->opener == LOCAL) return false; /* Does not apply if we already saw the funding tx. */ @@ -746,7 +746,7 @@ struct command_result *cancel_channel_before_broadcast(struct command *cmd, buffer + cidtok->start); } - if (cancel_channel->funder == REMOTE) + if (cancel_channel->opener == REMOTE) return command_fail(cmd, LIGHTNINGD, "Cannot cancel channel that was " "initiated by peer"); diff --git a/lightningd/closing_control.c b/lightningd/closing_control.c index d69310495..353d95b0a 100644 --- a/lightningd/closing_control.c +++ b/lightningd/closing_control.c @@ -217,7 +217,7 @@ void peer_start_closingd(struct channel *channel, * [BOLT #3](03-transactions.md#fee-calculation). */ final_commit_feerate = get_feerate(channel->channel_info.fee_states, - channel->funder, LOCAL); + channel->opener, LOCAL); feelimit = commit_tx_base_fee(final_commit_feerate, 0); /* Pick some value above slow feerate (or min possible if unknown) */ @@ -283,7 +283,7 @@ void peer_start_closingd(struct channel *channel, channel->funding, &channel->local_funding_pubkey, &channel->channel_info.remote_fundingkey, - channel->funder, + channel->opener, amount_msat_to_sat_round_down(channel->our_msat), amount_msat_to_sat_round_down(their_msat), channel->our_config.dust_limit, diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index a239122df..2a9f9ad1e 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -51,7 +51,7 @@ struct config { /* How long between changing commit and sending COMMIT message. */ u32 commit_time_ms; - /* Do we let the funder set any fee rate they want */ + /* Do we let the opener set any fee rate they want */ bool ignore_fee_limits; /* Number of blocks to rescan from the current head, or absolute diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index d6f0d0336..4102b5802 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -560,7 +560,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel, channel->shutdown_scriptpubkey[LOCAL], channel->shutdown_scriptpubkey[REMOTE], &final_key, - channel->funder, + channel->opener, &channel->local_basepoints, &channel->channel_info.theirbase, tx, diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 9224c3efb..a19b43751 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -64,7 +64,7 @@ struct uncommitted_channel { /* These are *not* filled in by new_uncommitted_channel: */ - /* Minimum funding depth (if funder == REMOTE). */ + /* Minimum funding depth (if opener == REMOTE). */ u32 minimum_depth; /* Our channel config. */ diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index b3e0db5b7..a737f9652 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -424,7 +424,7 @@ void channel_errmsg(struct channel *channel, /* We should immediately forget the channel if we receive error during * CHANNELD_AWAITING_LOCKIN if we are fundee. */ - if (!err_for_them && channel->funder == REMOTE + if (!err_for_them && channel->opener == REMOTE && channel->state == CHANNELD_AWAITING_LOCKIN) channel_fail_forget(channel, "%s: %s ERROR %s", channel->owner->name, @@ -453,7 +453,7 @@ static void json_add_htlcs(struct lightningd *ld, const struct htlc_out *hout; struct htlc_out_map_iter outi; u32 local_feerate = get_feerate(channel->channel_info.fee_states, - channel->funder, LOCAL); + channel->opener, LOCAL); /* FIXME: Add more fields. */ json_array_start(response, "htlcs"); @@ -526,7 +526,7 @@ static struct amount_sat commit_txfee(const struct channel *channel, struct lightningd *ld = channel->peer->ld; size_t num_untrimmed_htlcs = 0; u32 feerate = get_feerate(channel->channel_info.fee_states, - channel->funder, side); + channel->opener, side); struct amount_sat dust_limit; if (side == LOCAL) dust_limit = channel->our_config.dust_limit; @@ -656,7 +656,7 @@ static void json_add_channel(struct lightningd *ld, // FIXME @conscott : Modify this when dual-funded channels // are implemented json_object_start(response, "funding_allocation_msat"); - if (channel->funder == LOCAL) { + if (channel->opener == LOCAL) { json_add_u64(response, node_id_to_hexstr(tmpctx, &p->id), 0); json_add_u64(response, node_id_to_hexstr(tmpctx, &ld->id), channel->funding.satoshis * 1000); /* Raw: raw JSON field */ @@ -668,7 +668,7 @@ static void json_add_channel(struct lightningd *ld, json_object_end(response); json_object_start(response, "funding_msat"); - if (channel->funder == LOCAL) { + if (channel->opener == LOCAL) { json_add_sat_only(response, node_id_to_hexstr(tmpctx, &p->id), AMOUNT_SAT(0)); @@ -735,8 +735,8 @@ static void json_add_channel(struct lightningd *ld, /* Take away any currently-offered HTLCs. */ subtract_offered_htlcs(channel, &spendable); - /* If we're funder, subtract txfees we'll need to spend this */ - if (channel->funder == LOCAL) { + /* If we're opener, subtract txfees we'll need to spend this */ + if (channel->opener == LOCAL) { if (!amount_msat_sub_sat(&spendable, spendable, commit_txfee(channel, spendable, LOCAL))) @@ -767,8 +767,8 @@ static void json_add_channel(struct lightningd *ld, /* Take away any currently-offered HTLCs. */ subtract_received_htlcs(channel, &receivable); - /* If they're funder, subtract txfees they'll need to spend this */ - if (channel->funder == REMOTE) { + /* If they're opener, subtract txfees they'll need to spend this */ + if (channel->opener == REMOTE) { if (!amount_msat_sub_sat(&receivable, receivable, commit_txfee(channel, receivable, REMOTE))) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index b71513b80..ffc154785 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1676,7 +1676,7 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg) &fee_states, &changed_htlcs, &commit_sig, &htlc_sigs) - || !fee_states_valid(fee_states, channel->funder)) { + || !fee_states_valid(fee_states, channel->opener)) { channel_internal_error(channel, "bad channel_sending_commitsig %s", tal_hex(channel, msg)); return; @@ -1716,7 +1716,7 @@ void peer_sending_commitsig(struct channel *channel, const u8 *msg) channel->channel_info.fee_states = tal_steal(channel, fee_states); adjust_channel_feerate_bounds(channel, get_feerate(fee_states, - channel->funder, + channel->opener, REMOTE)); if (!peer_save_commitsig_sent(channel, commitnum)) @@ -1871,7 +1871,7 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg) &failed, &changed, &tx) - || !fee_states_valid(fee_states, channel->funder)) { + || !fee_states_valid(fee_states, channel->opener)) { channel_internal_error(channel, "bad fromwire_channel_got_commitsig %s", tal_hex(channel, msg)); @@ -1901,7 +1901,7 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg) log_debug(channel->log, "got commitsig %"PRIu64 ": feerate %u, %zu added, %zu fulfilled, %zu failed, %zu changed", - commitnum, get_feerate(fee_states, channel->funder, LOCAL), + commitnum, get_feerate(fee_states, channel->opener, LOCAL), tal_count(added), tal_count(fulfilled), tal_count(failed), tal_count(changed)); @@ -1934,7 +1934,7 @@ void peer_got_commitsig(struct channel *channel, const u8 *msg) channel->channel_info.fee_states = tal_steal(channel, fee_states); adjust_channel_feerate_bounds(channel, get_feerate(fee_states, - channel->funder, + channel->opener, LOCAL)); /* Since we're about to send revoke, bump state again. */ @@ -1982,7 +1982,7 @@ void peer_got_revoke(struct channel *channel, const u8 *msg) &next_per_commitment_point, &fee_states, &changed) - || !fee_states_valid(fee_states, channel->funder)) { + || !fee_states_valid(fee_states, channel->opener)) { channel_internal_error(channel, "bad fromwire_channel_got_revoke %s", tal_hex(channel, msg)); return; diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 40d25a6b1..50d0c041c 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -133,7 +133,7 @@ u32 get_block_height(const struct chain_topology *topo UNNEEDED) { fprintf(stderr, "get_block_height called!\n"); abort(); } /* Generated stub for get_feerate */ u32 get_feerate(const struct fee_states *fee_states UNNEEDED, - enum side funder UNNEEDED, + enum side opener UNNEEDED, enum side side UNNEEDED) { fprintf(stderr, "get_feerate called!\n"); abort(); } /* Generated stub for htlc_is_trimmed */ diff --git a/onchaind/onchain_wire.csv b/onchaind/onchain_wire.csv index ebff07fe6..298646d5f 100644 --- a/onchaind/onchain_wire.csv +++ b/onchaind/onchain_wire.csv @@ -27,7 +27,7 @@ msgdata,onchain_init,remote_scriptpubkey_len,u16, msgdata,onchain_init,remote_scriptpubkey,u8,remote_scriptpubkey_len msgdata,onchain_init,ourwallet_pubkey,pubkey, # We need these two for commit number obscurer -msgdata,onchain_init,funder,enum side, +msgdata,onchain_init,opener,enum side, msgdata,onchain_init,local_basepoints,basepoints, msgdata,onchain_init,remote_basepoints,basepoints, msgdata,onchain_init,tx,bitcoin_tx, diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index c2522ad67..830cd2726 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -705,7 +705,7 @@ static void unknown_spend(struct tracked_output *out, } static u64 unmask_commit_number(const struct bitcoin_tx *tx, - enum side funder, + enum side opener, const struct pubkey *local_payment_basepoint, const struct pubkey *remote_payment_basepoint) { @@ -718,7 +718,7 @@ static u64 unmask_commit_number(const struct bitcoin_tx *tx, * * The 48-bit commitment number is obscured by `XOR` with the lower 48 bits of... */ - obscurer = commit_number_obscurer(keys[funder], keys[!funder]); + obscurer = commit_number_obscurer(keys[opener], keys[!opener]); /* BOLT #3: * @@ -2648,7 +2648,7 @@ int main(int argc, char *argv[]) const tal_t *ctx = tal(NULL, char); u8 *msg; struct pubkey remote_per_commit_point, old_remote_per_commit_point; - enum side funder; + enum side opener; struct basepoints basepoints[NUM_SIDES]; struct shachain shachain; struct bitcoin_tx *tx; @@ -2686,7 +2686,7 @@ int main(int argc, char *argv[]) &scriptpubkey[LOCAL], &scriptpubkey[REMOTE], &our_wallet_pubkey, - &funder, + &opener, &basepoints[LOCAL], &basepoints[REMOTE], &tx, @@ -2763,7 +2763,7 @@ int main(int argc, char *argv[]) * *latest commitment transaction*. */ struct secret revocation_preimage; - commit_num = unmask_commit_number(tx, funder, + commit_num = unmask_commit_number(tx, opener, &basepoints[LOCAL].payment, &basepoints[REMOTE].payment); diff --git a/openingd/openingd.c b/openingd/openingd.c index 46e33f315..783582645 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -129,8 +129,8 @@ static u8 *dev_upfront_shutdown_script(const tal_t *ctx) } /*~ If we can't agree on parameters, we fail to open the channel. If we're - * the funder, we need to tell lightningd, otherwise it never really notices. */ -static void negotiation_aborted(struct state *state, bool am_funder, + * the opener, we need to tell lightningd, otherwise it never really notices. */ +static void negotiation_aborted(struct state *state, bool am_opener, const char *why) { status_debug("aborted opening negotiation: %s", why); @@ -143,7 +143,7 @@ static void negotiation_aborted(struct state *state, bool am_funder, peer_billboard(true, why); /* If necessary, tell master that funding failed. */ - if (am_funder) { + if (am_opener) { u8 *msg = towire_opening_funder_failed(NULL, why); wire_sync_write(REQ_FD, take(msg)); } @@ -161,7 +161,7 @@ static void negotiation_aborted(struct state *state, bool am_funder, } /*~ For negotiation failures: we tell them the parameter we didn't like. */ -static void negotiation_failed(struct state *state, bool am_funder, +static void negotiation_failed(struct state *state, bool am_opener, const char *fmt, ...) { va_list ap; @@ -176,7 +176,7 @@ static void negotiation_failed(struct state *state, bool am_funder, "You gave bad parameters: %s", errmsg); sync_crypto_write(state->pps, take(msg)); - negotiation_aborted(state, am_funder, errmsg); + negotiation_aborted(state, am_opener, errmsg); } /*~ This is the key function that checks that their configuration is reasonable: @@ -184,7 +184,7 @@ static void negotiation_failed(struct state *state, bool am_funder, * they've accepted our open. */ static bool check_config_bounds(struct state *state, const struct channel_config *remoteconf, - bool am_funder) + bool am_opener) { struct amount_sat capacity; struct amount_sat reserve; @@ -196,7 +196,7 @@ static bool check_config_bounds(struct state *state, * - `to_self_delay` is unreasonably large. */ if (remoteconf->to_self_delay > state->max_to_self_delay) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "to_self_delay %u larger than %u", remoteconf->to_self_delay, state->max_to_self_delay); @@ -219,7 +219,7 @@ static bool check_config_bounds(struct state *state, if (!amount_sat_add(&reserve, remoteconf->channel_reserve, state->localconf.channel_reserve)) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "channel_reserve_satoshis %s" " too large", type_to_string(tmpctx, struct amount_sat, @@ -229,7 +229,7 @@ static bool check_config_bounds(struct state *state, /* If reserves are larger than total sat, we fail. */ if (!amount_sat_sub(&capacity, state->funding, reserve)) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "channel_reserve_satoshis %s" " and %s too large for funding %s", type_to_string(tmpctx, struct amount_sat, @@ -250,7 +250,7 @@ static bool check_config_bounds(struct state *state, /* If the minimum htlc is greater than the capacity, the channel is * useless. */ if (amount_msat_greater_sat(remoteconf->htlc_minimum, capacity)) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "htlc_minimum_msat %s" " too large for funding %s" " capacity_msat %s", @@ -267,7 +267,7 @@ static bool check_config_bounds(struct state *state, * set by lightningd, don't bother opening it. */ if (amount_msat_greater_sat(state->min_effective_htlc_capacity, capacity)) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "channel capacity with funding %s," " reserves %s/%s," " max_htlc_value_in_flight_msat is %s," @@ -289,7 +289,7 @@ static bool check_config_bounds(struct state *state, /* We don't worry about how many HTLCs they accept, as long as > 0! */ if (remoteconf->max_accepted_htlcs == 0) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "max_accepted_htlcs %u invalid", remoteconf->max_accepted_htlcs); return false; @@ -302,7 +302,7 @@ static bool check_config_bounds(struct state *state, * - `max_accepted_htlcs` is greater than 483. */ if (remoteconf->max_accepted_htlcs > 483) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "max_accepted_htlcs %u too large", remoteconf->max_accepted_htlcs); return false; @@ -316,7 +316,7 @@ static bool check_config_bounds(struct state *state, */ if (amount_sat_greater(remoteconf->dust_limit, remoteconf->channel_reserve)) { - negotiation_failed(state, am_funder, + negotiation_failed(state, am_opener, "dust_limit_satoshis %s" " too large for channel_reserve_satoshis %s", type_to_string(tmpctx, struct amount_sat, @@ -367,7 +367,7 @@ static void temporary_channel_id(struct channel_id *channel_id) /*~ Handle random messages we might get during opening negotiation, (eg. gossip) * returning the first non-handled one, or NULL if we aborted negotiation. */ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, - bool am_funder) + bool am_opener) { /* This is an event loop of its own. That's generally considered poor * form, but we use it in a very limited way. */ @@ -429,7 +429,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, } /* Close connection on all_channels error. */ if (all_channels) { - if (am_funder) { + if (am_opener) { msg = towire_opening_funder_failed(NULL, err); wire_sync_write(REQ_FD, take(msg)); @@ -437,7 +437,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state, peer_failed_received_errmsg(state->pps, err, NULL, false); } - negotiation_aborted(state, am_funder, + negotiation_aborted(state, am_opener, tal_fmt(tmpctx, "They sent error %s", err)); /* Return NULL so caller knows to stop negotiating. */ @@ -507,7 +507,7 @@ static bool setup_channel_funder(struct state *state) return true; } -/* We start the 'fund a channel' negotation with the supplied peer, but +/* We start the 'open a channel' negotation with the supplied peer, but * stop when we get to the part where we need the funding txid */ static u8 *funder_channel_start(struct state *state, u8 channel_flags) { @@ -1065,7 +1065,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) return NULL; } - /* These checks are the same whether we're funder or fundee... */ + /* These checks are the same whether we're opener or accepter... */ if (!check_config_bounds(state, &state->remoteconf, false)) return NULL; diff --git a/tests/test_closing.py b/tests/test_closing.py index f61a1cd1d..5731de5aa 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -362,32 +362,32 @@ def test_closing_specified_destination(node_factory, bitcoind, chainparams): def closing_negotiation_step(node_factory, bitcoind, chainparams, opts): rate = 29006 # closing fee negotiation starts at 21000 - funder = node_factory.get_node(feerates=(rate, rate, rate, rate)) + opener = node_factory.get_node(feerates=(rate, rate, rate, rate)) rate = 27625 # closing fee negotiation starts at 20000 - fundee = node_factory.get_node(feerates=(rate, rate, rate, rate)) + peer = node_factory.get_node(feerates=(rate, rate, rate, rate)) - funder_id = funder.info['id'] - fundee_id = fundee.info['id'] + opener_id = opener.info['id'] + peer_id = peer.info['id'] fund_amount = 10**6 - funder.rpc.connect(fundee_id, 'localhost', fundee.port) - funder.fund_channel(fundee, fund_amount) + opener.rpc.connect(peer_id, 'localhost', peer.port) + opener.fund_channel(peer, fund_amount) assert bitcoind.rpc.getmempoolinfo()['size'] == 0 - if opts['close_initiated_by'] == 'funder': - funder.rpc.close(peer_id=fundee_id, fee_negotiation_step=opts['fee_negotiation_step']) + if opts['close_initiated_by'] == 'opener': + opener.rpc.close(peer_id=peer_id, fee_negotiation_step=opts['fee_negotiation_step']) else: - assert opts['close_initiated_by'] == 'fundee' - fundee.rpc.close(peer_id=funder_id, fee_negotiation_step=opts['fee_negotiation_step']) + assert opts['close_initiated_by'] == 'peer' + peer.rpc.close(peer_id=opener_id, fee_negotiation_step=opts['fee_negotiation_step']) # Get the proclaimed closing fee from the two nodes' statuses status_agreed_regex = re.compile("agreed on a closing fee of ([0-9]+) satoshi") - # [fee_from_funder_status, fee_from_fundee_status] + # [fee_from_opener_status, fee_from_peer_status] fees_from_status = [None, None] def get_fee_from_status(node, peer_id, i): @@ -399,8 +399,8 @@ def closing_negotiation_step(node_factory, bitcoind, chainparams, opts): fees_from_status[i] = int(m.group(1)) return True - wait_for(lambda: get_fee_from_status(funder, fundee_id, 0)) - wait_for(lambda: get_fee_from_status(fundee, funder_id, 1)) + wait_for(lambda: get_fee_from_status(opener, peer_id, 0)) + wait_for(lambda: get_fee_from_status(peer, opener_id, 1)) assert opts['expected_close_fee'] == fees_from_status[0] assert opts['expected_close_fee'] == fees_from_status[1] @@ -429,11 +429,11 @@ def test_closing_negotiation_step_30pct(node_factory, bitcoind, chainparams): opts = {} opts['fee_negotiation_step'] = '30%' - opts['close_initiated_by'] = 'funder' + opts['close_initiated_by'] = 'opener' opts['expected_close_fee'] = 20537 if not chainparams['elements'] else 33870 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) - opts['close_initiated_by'] = 'fundee' + opts['close_initiated_by'] = 'peer' opts['expected_close_fee'] = 20233 if not chainparams['elements'] else 33366 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) @@ -443,11 +443,11 @@ def test_closing_negotiation_step_50pct(node_factory, bitcoind, chainparams): opts = {} opts['fee_negotiation_step'] = '50%' - opts['close_initiated_by'] = 'funder' + opts['close_initiated_by'] = 'opener' opts['expected_close_fee'] = 20334 if not chainparams['elements'] else 33533 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) - opts['close_initiated_by'] = 'fundee' + opts['close_initiated_by'] = 'peer' opts['expected_close_fee'] = 20334 if not chainparams['elements'] else 33533 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) @@ -457,16 +457,16 @@ def test_closing_negotiation_step_100pct(node_factory, bitcoind, chainparams): opts = {} opts['fee_negotiation_step'] = '100%' - opts['close_initiated_by'] = 'funder' + opts['close_initiated_by'] = 'opener' opts['expected_close_fee'] = 20001 if not chainparams['elements'] else 32985 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) # The close fee of 20499 looks strange in this case - one would expect # to have a number close to 21000. This is because - # * the range is initially set to [20000 (fundee), 21000 (funder)] - # * the funder is always first to propose, he uses 50% step, so he proposes 20500 - # * the range is narrowed to [20001, 20499] and the fundee proposes 20499 - opts['close_initiated_by'] = 'fundee' + # * the range is initially set to [20000 (peer), 21000 (opener)] + # * the opener is always first to propose, he uses 50% step, so he proposes 20500 + # * the range is narrowed to [20001, 20499] and the peer proposes 20499 + opts['close_initiated_by'] = 'peer' opts['expected_close_fee'] = 20499 if not chainparams['elements'] else 33808 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) @@ -476,11 +476,11 @@ def test_closing_negotiation_step_1sat(node_factory, bitcoind, chainparams): opts = {} opts['fee_negotiation_step'] = '1' - opts['close_initiated_by'] = 'funder' + opts['close_initiated_by'] = 'opener' opts['expected_close_fee'] = 20989 if not chainparams['elements'] else 34621 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) - opts['close_initiated_by'] = 'fundee' + opts['close_initiated_by'] = 'peer' opts['expected_close_fee'] = 20010 if not chainparams['elements'] else 32995 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) @@ -490,11 +490,11 @@ def test_closing_negotiation_step_700sat(node_factory, bitcoind, chainparams): opts = {} opts['fee_negotiation_step'] = '700' - opts['close_initiated_by'] = 'funder' + opts['close_initiated_by'] = 'opener' opts['expected_close_fee'] = 20151 if not chainparams['elements'] else 33459 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) - opts['close_initiated_by'] = 'fundee' + opts['close_initiated_by'] = 'peer' opts['expected_close_fee'] = 20499 if not chainparams['elements'] else 33746 closing_negotiation_step(node_factory, bitcoind, chainparams, opts) @@ -686,7 +686,7 @@ def test_penalty_outhtlc(node_factory, bitcoind, executor, chainparams): @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_onchain_first_commit(node_factory, bitcoind): - """Onchain handling where funder immediately drops to chain""" + """Onchain handling where opener immediately drops to chain""" # HTLC 1->2, 1 fails just after funding. disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail'] diff --git a/tests/test_connection.py b/tests/test_connection.py index 0c06a85b6..69d67d827 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -161,11 +161,11 @@ def test_opening_tiny_channel(node_factory): dustlimit = 546 reserves = 2 * dustlimit min_commit_tx_fees = 5430 - min_for_funder = min_commit_tx_fees + dustlimit + 1 + min_for_opener = min_commit_tx_fees + dustlimit + 1 l1_min_capacity = 1000 # 1k old default, too small but used at l1 to allow small incoming channels l2_min_capacity = reserves # just enough to get past capacity filter - l3_min_capacity = min_for_funder # the absolute technical minimum + l3_min_capacity = min_for_opener # the absolute technical minimum l4_min_capacity = 10000 # the current default l5_min_capacity = 20000 # a server with more than default minimum @@ -184,7 +184,7 @@ def test_opening_tiny_channel(node_factory): with pytest.raises(RpcError, match=r'channel_reserve_satoshis .*sat and .*sat too large for funding .*sat'): l1.fund_channel(l2, l2_min_capacity - 1) # Open a channel with exactly the minimal amount for the fundee, - # This will raise an exception at l1, as the funder cannot afford fees for initial_commit_tx. + # This will raise an exception at l1, as the opener cannot afford fees for initial_commit_tx. # Note: The old default of 1k sat is below the technical minimum when accounting for dust reserves and fees # This is why this must fail, for this reason the default will be raised to 10k sat. with pytest.raises(RpcError, match=r'Funder cannot afford fee on initial commitment transaction'): @@ -247,8 +247,8 @@ def test_disconnect(node_factory): @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") -def test_disconnect_funder(node_factory): - # Now error on funder side duringchannel open. +def test_disconnect_opener(node_factory): + # Now error on opener side during channel open. disconnects = ['-WIRE_OPEN_CHANNEL', '@WIRE_OPEN_CHANNEL', '+WIRE_OPEN_CHANNEL', @@ -303,7 +303,7 @@ def test_disconnect_fundee(node_factory): @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_disconnect_half_signed(node_factory): # Now, these are the corner cases. Fundee sends funding_signed, - # but funder doesn't receive it. + # but opener doesn't receive it. disconnects = ['@WIRE_FUNDING_SIGNED'] l1 = node_factory.get_node() l2 = node_factory.get_node(disconnect=disconnects) @@ -314,7 +314,7 @@ def test_disconnect_half_signed(node_factory): with pytest.raises(RpcError): l1.rpc.fundchannel(l2.info['id'], 20000) - # Fundee remembers, funder doesn't. + # Peer remembers, opener doesn't. assert l1.rpc.getpeer(l2.info['id']) is None assert l2.rpc.getpeer(l1.info['id'])['id'] == l1.info['id'] @@ -348,7 +348,7 @@ def test_reconnect_signed(node_factory): @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_reconnect_openingd(node_factory): - # Openingd thinks we're still opening; funder reconnects.. + # Openingd thinks we're still opening; opener reconnects.. disconnects = ['0WIRE_ACCEPT_CHANNEL'] l1 = node_factory.get_node(may_reconnect=True) l2 = node_factory.get_node(disconnect=disconnects, @@ -1649,13 +1649,13 @@ def test_fundee_forget_funding_tx_unconfirmed(node_factory, bitcoind): # could time out before lightningd processes all the # blocks. blocks = 200 - # funder + # opener l1 = node_factory.get_node() - # fundee + # peer l2 = node_factory.get_node(options={"dev-max-funding-unconfirmed-blocks": blocks}) l1.rpc.connect(l2.info['id'], 'localhost', l2.port) - # Give funder some funds. + # Give opener some funds. l1.fundwallet(10**7) # Let blocks settle. time.sleep(1) @@ -1663,11 +1663,11 @@ def test_fundee_forget_funding_tx_unconfirmed(node_factory, bitcoind): def mock_sendrawtransaction(r): return {'id': r['id'], 'error': {'code': 100, 'message': 'sendrawtransaction disabled'}} - # Prevent funder from broadcasting funding tx (any tx really). + # Prevent opener from broadcasting funding tx (any tx really). l1.daemon.rpcproxy.mock_rpc('sendrawtransaction', mock_sendrawtransaction) # Fund the channel. - # The process will complete, but funder will be unable + # The process will complete, but opener will be unable # to broadcast and confirm funding tx. with pytest.raises(RpcError, match=r'sendrawtransaction disabled'): l1.rpc.fundchannel(l2.info['id'], 10**6) @@ -1764,7 +1764,7 @@ def test_no_fee_estimate(node_factory, bitcoind, executor): @unittest.skipIf(not DEVELOPER, "needs --dev-disconnect") -def test_funder_feerate_reconnect(node_factory, bitcoind): +def test_opener_feerate_reconnect(node_factory, bitcoind): # l1 updates fees, then reconnect so l2 retransmits commitment_signed. disconnects = ['-WIRE_COMMITMENT_SIGNED*3'] l1 = node_factory.get_node(may_reconnect=True, @@ -1788,7 +1788,7 @@ def test_funder_feerate_reconnect(node_factory, bitcoind): l1.pay(l2, 200000000) -def test_funder_simple_reconnect(node_factory, bitcoind): +def test_opener_simple_reconnect(node_factory, bitcoind): """Sanity check that reconnection works with completely unused channels""" # Set fees even so it doesn't send any commitments. l1 = node_factory.get_node(may_reconnect=True, @@ -2127,7 +2127,7 @@ def test_change_chaining(node_factory, bitcoind): def test_feerate_spam(node_factory, chainparams): l1, l2 = node_factory.line_graph(2) - # We constrain the value the funder has at its disposal so we get the + # We constrain the value the opener has at its disposal so we get the # REMOTE feerate we are looking for below. This may be fragile and depends # on the transactions we generate. slack = 45000000 if not chainparams['elements'] else 68000000 diff --git a/tests/test_pay.py b/tests/test_pay.py index fad831c1d..16a541914 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -1566,22 +1566,22 @@ def test_pay_variants(node_factory): def test_pay_retry(node_factory, bitcoind, executor, chainparams): """Make sure pay command retries properly. """ - def exhaust_channel(funder, fundee, scid, already_spent=0): + def exhaust_channel(opener, peer, scid, already_spent=0): """Spend all available capacity (10^6 - 1%) of channel """ - peer = funder.rpc.listpeers(fundee.info['id'])['peers'][0] - chan = peer['channels'][0] + peer_node = opener.rpc.listpeers(peer.info['id'])['peers'][0] + chan = peer_node['channels'][0] maxpay = chan['spendable_msatoshi'] lbl = ''.join(random.choice(string.ascii_letters) for _ in range(20)) - inv = fundee.rpc.invoice(maxpay, lbl, "exhaust_channel") + inv = peer.rpc.invoice(maxpay, lbl, "exhaust_channel") routestep = { 'msatoshi': maxpay, - 'id': fundee.info['id'], + 'id': peer.info['id'], 'delay': 10, 'channel': scid } - funder.rpc.sendpay([routestep], inv['payment_hash']) - funder.rpc.waitsendpay(inv['payment_hash']) + opener.rpc.sendpay([routestep], inv['payment_hash']) + opener.rpc.waitsendpay(inv['payment_hash']) # We connect every node to l5; in a line and individually. # Keep fixed fees so we can easily calculate exhaustion @@ -2344,7 +2344,7 @@ def test_channel_spendable_receivable_capped(node_factory, bitcoind): def test_lockup_drain(node_factory, bitcoind): - """Try to get channel into a state where funder can't afford fees on additional HTLC, so fundee can't add HTLC""" + """Try to get channel into a state where opener can't afford fees on additional HTLC, so peer can't add HTLC""" l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True}) # l1 sends all the money to l2 until even 1 msat can't get through. diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 3a12cda37..990dfea21 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -1039,8 +1039,8 @@ static bool channelseq(struct channel *c1, struct channel *c2) CHECK(pubkey_eq(&ci1->remote_per_commit, &ci2->remote_per_commit)); CHECK(pubkey_eq(&ci1->old_remote_per_commit, &ci2->old_remote_per_commit)); CHECK(ci1->their_config.id != 0 && ci1->their_config.id == ci2->their_config.id); - CHECK(fee_states_valid(ci1->fee_states, c1->funder)); - CHECK(fee_states_valid(ci2->fee_states, c2->funder)); + CHECK(fee_states_valid(ci1->fee_states, c1->opener)); + CHECK(fee_states_valid(ci2->fee_states, c2->opener)); for (enum htlc_state i = 0; i < ARRAY_SIZE(ci1->fee_states->feerate); i++) { if (ci1->fee_states->feerate[i] == NULL) { @@ -1125,7 +1125,7 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx) pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk); node_id_from_pubkey(&id, &pk); feerate = 31337; - ci->fee_states = new_fee_states(w, c1.funder, &feerate); + ci->fee_states = new_fee_states(w, c1.opener, &feerate); mempat(scriptpubkey, tal_count(scriptpubkey)); c1.first_blocknum = 1; parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false, diff --git a/wallet/wallet.c b/wallet/wallet.c index 86f1b6c0f..071bfa795 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -817,7 +817,7 @@ fail: static struct fee_states *wallet_channel_fee_states_load(struct wallet *w, const u64 id, - enum side funder) + enum side opener) { struct fee_states *fee_states; struct db_stmt *stmt; @@ -827,7 +827,7 @@ static struct fee_states *wallet_channel_fee_states_load(struct wallet *w, db_query_prepared(stmt); /* Start with blank slate. */ - fee_states = new_fee_states(w, funder, NULL); + fee_states = new_fee_states(w, opener, NULL); while (db_step(stmt)) { enum htlc_state hstate = db_column_int(stmt, 0); u32 feerate = db_column_int(stmt, 1); @@ -843,7 +843,7 @@ static struct fee_states *wallet_channel_fee_states_load(struct wallet *w, } tal_free(stmt); - if (fee_states && !fee_states_valid(fee_states, funder)) { + if (fee_states && !fee_states_valid(fee_states, opener)) { log_broken(w->log, "invalid channel_feerates for id %"PRIu64, id); fee_states = tal_free(fee_states); @@ -1359,7 +1359,7 @@ void wallet_channel_save(struct wallet *w, struct channel *chan) else db_bind_null(stmt, 1); db_bind_int(stmt, 2, chan->state); - db_bind_int(stmt, 3, chan->funder); + db_bind_int(stmt, 3, chan->opener); db_bind_int(stmt, 4, chan->channel_flags); db_bind_int(stmt, 5, chan->minimum_depth);