Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
aeb8c88
amount: helper method for adding sats to an msat amount
niftynei Sep 19, 2019
009b1e7
df: rename 'funder' to 'opener'
niftynei Sep 9, 2019
c7b9dff
df: add wires for dual funding messages
niftynei Sep 10, 2019
17b41fa
df: pipe through whether or not we're using v2
niftynei Sep 13, 2019
a97541c
df: switch from funding -> opener_funding and wire in v2 calls
niftynei Sep 13, 2019
42f05f7
df: stash 'is_v2' into fundchannel object
niftynei Sep 13, 2019
2d8e26f
df: lookup transaction for the fundchannel_complete
niftynei Sep 13, 2019
a77bf7d
hsmd: pull up utxo signing
niftynei Sep 17, 2019
bef7209
withdraw: refactor change output handling
niftynei Sep 17, 2019
db3f615
withdraw: add ability to have additional inputs on a tx
niftynei Sep 17, 2019
fce1520
walletrpc: break out output extraction code
niftynei Sep 17, 2019
e550f6a
funding: add method for building a dual-funded tx
niftynei Sep 19, 2019
c8d4aa1
opening: update wallet_commit_channel for df
niftynei Sep 19, 2019
e1d6ded
funding: pass utxos through to openingd
niftynei Sep 19, 2019
f6ed18f
dual-funding: wire up opener side of dual funding
niftynei Sep 19, 2019
e4173bf
fundchannel_complete: return 'txid' and 'remote signed' tx
niftynei Sep 19, 2019
7762fae
df: wire in feature flag
niftynei Sep 19, 2019
5c0bd16
utxos: pass through the scriptpubkey
niftynei Sep 23, 2019
7dfe35e
txprepare: zero out change if asked
niftynei Sep 30, 2019
576444e
zero_out_change: add to pylightning
niftynei Oct 8, 2019
2cb4da1
wire: add dual-funding subtypes to list
niftynei Sep 30, 2019
f66a35d
wallet-df: save our_funds amount to channel record
niftynei Sep 30, 2019
9cc6bec
utxo: add scriptSig field
niftynei Sep 30, 2019
95a1fd4
channeld: add flag for whether channel has our funds
niftynei Sep 30, 2019
04986a6
df: pass opener's change through so we can update utx
niftynei Sep 30, 2019
7913287
hsmd: add method for signing dual funded txs
niftynei Sep 30, 2019
2ac8577
hsmd: allow openingd to call hsm to sign dual-funded tx
niftynei Sep 30, 2019
3ba492d
wallet: method to compute available funds for df
niftynei Sep 30, 2019
eef704b
fundchannel: update to work with dual funding
niftynei Sep 30, 2019
5e44b47
listpeers: show funding_allocation for df'd channels
niftynei Sep 30, 2019
8af5018
df-accepter: pass v2 info back to opening_control
niftynei Sep 30, 2019
0690641
df-accepter: if payload is v2, calculate available funds
niftynei Sep 30, 2019
ce4e3e8
fundchannel_start: include version of open protocol
niftynei Sep 30, 2019
0df73e1
df-accepter: accepter logic
niftynei Sep 30, 2019
6f48337
openchannel: add dual-funding fields to hook
niftynei Sep 30, 2019
d19c83f
plugins: add documentation for openchannel v2 fields
niftynei Oct 10, 2019
3fddfec
passback error on overflow
niftynei Nov 13, 2019
70692cf
no-asserts: move sat addition logic out of asserts
niftynei Nov 13, 2019
ef0327c
bitcoin_tx: add helper for extracting output amount
niftynei Nov 14, 2019
42e5a5b
df: report overflows in remote inputs/outputs as peer err
niftynei Nov 14, 2019
412fde8
openchannel: make open_channel_version a number, not a string
niftynei Nov 14, 2019
665454a
df: update BOLT refs to match PR
niftynei Nov 14, 2019
55beabe
df: add BOLT references for dual funding to funding_tx + test
niftynei Nov 15, 2019
9e57c88
DB: do not swallow error on channel load
niftynei Nov 19, 2019
c9e4941
df: check that inputs are unique
niftynei Nov 21, 2019
93030ef
df: verify that funding output not included
niftynei Nov 21, 2019
74b3df7
df: port to new input/output dance
niftynei Nov 21, 2019
86adfed
df: include input info on witness data
niftynei Dec 2, 2019
07c1119
df: add remote's witnesses to unreleased tx object
niftynei Dec 2, 2019
0ad86de
df: convert accepter_sigs to new pattern, add input check
niftynei Dec 2, 2019
d55ffe9
mocks: update the mocks (while rebasing)
niftynei Feb 7, 2020
4e86992
df: save incoming peer messages until we return
niftynei Dec 2, 2019
0ab1aae
df: fixup, need to pass a not null in to to/from wire
niftynei Dec 2, 2019
dd026ff
dual-funding: confirm scriptpubkey matches what's onchain
niftynei Oct 9, 2019
ba88dc5
df/wallet: add expiring leases to output reservations
niftynei Sep 10, 2019
d45aeec
wallet/df: set priority on utxo for spending
niftynei Dec 6, 2019
98bdb6d
wallet: include reserved outputs in listfunds
niftynei Dec 6, 2019
886656a
df: mark reserved accepter utxos with an expiration
niftynei Dec 6, 2019
a7e8bbc
wallet watch: track and clean up many inputs:channel opens
niftynei Dec 12, 2019
a0ef6ff
wallet test: add test for utxo tracking cleanup
niftynei Dec 14, 2019
21a0330
wallet tests: print error instead of non-entity
niftynei Dec 14, 2019
1647ffb
df: use correct check for p2sh-wrapped pay to witness
niftynei Dec 14, 2019
900bd20
channel control: don't forget a channel if we added funds
niftynei Dec 14, 2019
529ce2b
opening: plumb through amounts for a transaction
niftynei Oct 8, 2019
7b8bcb5
withdraw: sanity checks in hsm
niftynei Oct 8, 2019
c8007b5
df: initialize change input
niftynei Dec 16, 2019
bcab452
df: add tests for burning + df
niftynei Oct 8, 2019
ecafa3a
df: make version an int not a string
niftynei Dec 17, 2019
bd0a944
df: fixup miscalculation in funding transaction builder
niftynei Dec 18, 2019
5a3398a
funding: fixup broken unit test for funding calc
niftynei Dec 18, 2019
77227be
gitignore: ignore external lib libbase58
niftynei Dec 18, 2019
cdcfa37
gitignore: ignore release directory
niftynei Dec 18, 2019
4e2584a
tx_add_input: fix problems with tx_add_input
niftynei Jan 17, 2020
5a70470
df: add test for double spending a dual funding input
niftynei Jan 17, 2020
6e0ec1d
df: reveal utxo reservation info in listfunds
niftynei Dec 19, 2019
1ef8143
reserved: on start, make sure that reserved utxos stay reserved
niftynei Dec 19, 2019
6b040d5
tests: add test for the original node broadcasting the tx
niftynei Dec 19, 2019
4962933
test fixup: check for RBF of other channel is triggered
niftynei Dec 20, 2019
9a73883
txowatch: pass in chaintopology to callback
niftynei Jan 13, 2020
6b0c151
utxo watch: wait to initiate watches until after channels are populated
niftynei Jan 13, 2020
a3233c1
df: send remote's inputs over to lightningd
niftynei Jan 13, 2020
9e1ce1b
remove unused input checking; transitioning to watches
niftynei Jan 13, 2020
0cf447a
channel: add a field for hanging txowatches off of
niftynei Jan 13, 2020
f3e8549
channel_control: allow forgetter to signal whether to notify peer
niftynei Jan 13, 2020
922e6de
funding: track funding inputs until spent
niftynei Jan 13, 2020
0d255c8
channel: helpers for declaring a channel borked/active
niftynei Jan 13, 2020
384ec94
channel: on a permanent failure, only drop to chain if not borked
niftynei Jan 13, 2020
c186c0a
channel: update 'active' to exclude any borked channels
niftynei Jan 13, 2020
65ed74d
close: borked channels can't be closed
niftynei Jan 13, 2020
5793d83
channel: check if we have funds in channel before forgetting
niftynei Jan 13, 2020
b0e4a5c
wallet outputs: move output state to spent when spent_height updated
niftynei Jan 13, 2020
29fa621
borked: re-instate info about borked transactions at start/restart
niftynei Jan 13, 2020
d6367ee
test: add BORKED channel state to invoice channel selection test
niftynei Jan 13, 2020
72c4163
cancel: don't allow fundchannel_cancel for borked channels
niftynei Jan 14, 2020
da1f20a
borked: add small check that borked channels are counted correctly
niftynei Jan 14, 2020
52bf052
borked: clean up active_channel lookups to account for borking
niftynei Jan 14, 2020
4c69ed7
borked: update billboard to reflect the fact that channel is borked
niftynei Jan 14, 2020
59cc57d
tests: update upfront close to use the dual-funded pathway
niftynei Jan 16, 2020
536755a
fixup funder test: use new namespace
niftynei Jan 24, 2020
9d059aa
test-util: add EXPERIMENTAL_FEATURES variable
niftynei Feb 4, 2020
b97ceca
fixup: wallet-df: save our_funds amount to channel record
niftynei Feb 4, 2020
904c0d2
tests: fixup disconnects failure
niftynei Feb 4, 2020
b794113
tests: update openchannel hook test to be aware of v2 format
niftynei Feb 5, 2020
d3351ab
tests: more dev_disconnect updates WIRE_COMMITMENT_SIGNED reuse
niftynei Feb 5, 2020
fa2e6c4
fixup tests: update version to include dual-funding number
niftynei Feb 5, 2020
03cd27f
tests: switch out disconnect message depending on version?
niftynei Feb 5, 2020
4849fcd
test: connect before funding in fundchannel
niftynei Feb 5, 2020
be9a3ae
tests: abort fundchannel_start tests if v2 is being used
niftynei Feb 5, 2020
6b929b8
openingd: negotiation_failed should return/abort
niftynei Feb 5, 2020
92b8fae
tests: mark cancel race test as skipped if using v2
niftynei Feb 5, 2020
af7d918
tests: move all v2 'disabled' tests due to no extrnal v2 to 'skipped'
niftynei Feb 5, 2020
fefd295
fixup: utxo initiation missing new fields
niftynei Feb 11, 2020
565e7d6
test-patch: switch on disconnects depending on EXP_FEATURES
niftynei Feb 12, 2020
0a791a8
df: update to 'interactive tx construction' draft protocols
niftynei Feb 21, 2020
335ec00
df: update channel id to sha256 of revocation basepoints
niftynei Feb 25, 2020
1ce1051
tx_locktime: port over locktime logic from bitcoind
niftynei Mar 12, 2020
855ad92
df: wire up using adaptive locktime for dual-funding
niftynei Mar 12, 2020
5d018d1
df: use RBF'able sequence for all inputs in dual-funded txs
niftynei Mar 12, 2020
c594137
bcli-bugfix: pass along entire script
niftynei May 1, 2020
24c31e3
wire: suppress printout from patch command
niftynei May 1, 2020
0e796e5
fixup! df: wire in feature flag
niftynei May 6, 2020
b444ece
fixup! df: update to 'interactive tx construction' draft protocols
niftynei May 6, 2020
a6993c5
df-interactive: there's no counts in the interactive protocol
niftynei May 6, 2020
a8fb612
interactive: the max is now wallet max, not bounded
niftynei May 6, 2020
f0688a6
fixup! df: update channel id to sha256 of revocation basepoints
niftynei May 6, 2020
5f8a82b
fixup! df: update to 'interactive tx construction' draft protocols
niftynei May 6, 2020
8fa174e
interactive: don't send completes at every juncture
niftynei May 6, 2020
b86c9e6
fixup! df: update to 'interactive tx construction' draft protocols
niftynei May 6, 2020
533ed16
mock updates??
niftynei May 6, 2020
6f892c1
fixup! df: update to 'interactive tx construction' draft protocols
niftynei May 6, 2020
9dac1fc
interactive: flag for whether to include 'common' fields
niftynei May 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ config.vars
external/libbacktrace-build/
external/libbacktrace.a
external/libbacktrace.la
external/libbase58/
external/libbase58.a
test/test_protocol
test/test_sphinx
tests/.pytest.restart
Expand All @@ -44,4 +46,5 @@ contrib/pylightning/pylightning.egg-info/
contrib/pyln-*/build/
contrib/pyln-*/dist/
contrib/pyln-*/pyln_*.egg-info/
plugins/keysend
plugins/keysend
release/
32 changes: 32 additions & 0 deletions bitcoin/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,38 @@ u8 *p2wpkh_scriptcode(const tal_t *ctx, const struct pubkey *key)
return script;
}

bool is_p2sh_p2wpkh_redeemscript(const u8 *script)
{
size_t script_len = tal_count(script);

/* Prefaced by the length */
if (script_len != BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN + 1)
return false;
if (script[0] != OP_PUSHBYTES(22))
return false;
if (script[1] != OP_0)
return false;
if (script[2] != OP_PUSHBYTES(20))
return false;
return true;
}

bool is_p2sh_p2wsh_redeemscript(const u8 *script)
{
size_t script_len = tal_count(script);

/* Is prefaced by the length */
if (script_len != BITCOIN_SCRIPTPUBKEY_P2WSH_LEN + 1)
return false;
if (script[0] != OP_PUSHBYTES(34))
return false;
if (script[1] != OP_0)
return false;
if (script[2] != OP_PUSHBYTES(32))
return false;
return true;
}

bool is_p2pkh(const u8 *script, struct bitcoin_address *addr)
{
size_t script_len = tal_count(script);
Expand Down
6 changes: 6 additions & 0 deletions bitcoin/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ u8 *bitcoin_wscript_htlc_tx(const tal_t *ctx,
const struct pubkey *revocation_pubkey,
const struct pubkey *local_delayedkey);

/* Is this a P2SH-P2WPKH redeemscript? */
bool is_p2sh_p2wpkh_redeemscript(const u8 *script);

/* Is this a P2SH-P2WSH redeemscript? */
bool is_p2sh_p2wsh_redeemscript(const u8 *script);

/* Is this a pay to pubkey hash? (extract addr if not NULL) */
bool is_p2pkh(const u8 *script, struct bitcoin_address *addr);

Expand Down
21 changes: 19 additions & 2 deletions bitcoin/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

#define SEGREGATED_WITNESS_FLAG 0x1

struct bitcoin_tx_output *new_tx_output(const tal_t *ctx,
struct amount_sat amount,
const u8 *script)
{
struct bitcoin_tx_output *output = tal(ctx, struct bitcoin_tx_output);
output->amount = amount;
output->script = tal_dup_arr(output, u8, script, tal_count(script), 0);
return output;
}

int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
struct amount_sat amount)
{
Expand Down Expand Up @@ -160,9 +170,10 @@ int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,

/* Now store the input amount if we know it, so we can sign later */
if (tal_count(tx->input_amounts) < tx->wtx->num_inputs)
tal_resize(&tx->input_amounts, tx->wtx->num_inputs);
tal_resizez(&tx->input_amounts, tx->wtx->num_inputs);

tx->input_amounts[i] = tal_free(tx->input_amounts[i]);
if (tx->input_amounts[i])
tx->input_amounts[i] = tal_free(tx->input_amounts[i]);
tx->input_amounts[i] = tal_dup(tx, struct amount_sat, &amount);

return i;
Expand Down Expand Up @@ -228,6 +239,12 @@ const u8 *bitcoin_tx_output_get_script(const tal_t *ctx,
return res;
}

void bitcoin_tx_output_get_amount_sat(struct bitcoin_tx *tx, int outnum,
struct amount_sat *amount)
{
amount->satoshis = tx->wtx->outputs[outnum].satoshi; /* Raw: type conversion */
}

/* FIXME(cdecker) Make the caller pass in a reference to amount_asset, and
* return false if unintelligible/encrypted. (WARN UNUSED). */
struct amount_asset bitcoin_tx_output_get_amount(const struct bitcoin_tx *tx,
Expand Down
16 changes: 15 additions & 1 deletion bitcoin/tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <wally_transaction.h>

#define BITCOIN_TX_DEFAULT_SEQUENCE 0xFFFFFFFF
#define BITCOIN_TX_RBF_SEQUENCE 0xFFFFFFFD

struct witscript {
u8 *ptr;
Expand Down Expand Up @@ -46,10 +47,16 @@ struct bitcoin_tx_input {
u8 *script;
u32 sequence_number;

/* Only if BIP141 used. */
/* If BIP141 used, or is external input */
u8 **witness;

/* Needed for external inputs */
struct amount_sat amount;
};

struct bitcoin_tx_output *new_tx_output(const tal_t *ctx,
struct amount_sat amount,
const u8 *script);

/* SHA256^2 the tx: simpler than sha256_tx */
void bitcoin_txid(const struct bitcoin_tx *tx, struct bitcoin_txid *txid);
Expand Down Expand Up @@ -115,6 +122,13 @@ void bitcoin_tx_output_set_amount(struct bitcoin_tx *tx, int outnum,
*/
const u8 *bitcoin_tx_output_get_script(const tal_t *ctx, const struct bitcoin_tx *tx, int outnum);

/** bitcoin_tx_output_get_amount_sat - Helper to get transaction output's amount
*
* Internally we use a `wally_tx` to represent the transaction. The
* satoshi amount isn't a struct amount_sat, so we need a conversion
*/
void bitcoin_tx_output_get_amount_sat(struct bitcoin_tx *tx, int outnum,
struct amount_sat *amount);
/**
* Helper to just get an amount_sat for the output amount.
*/
Expand Down
1 change: 1 addition & 0 deletions channeld/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CHANNELD_COMMON_OBJS := \
common/ecdh_hsmd.o \
common/features.o \
common/fee_states.o \
common/funding_tx.o \
common/gen_status_wire.o \
common/gen_peer_status_wire.o \
common/gossip_rcvd_filter.o \
Expand Down
3 changes: 2 additions & 1 deletion channeld/channel_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ 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,local_funded,bool,
msgdata,channel_init,fee_base,u32,
msgdata,channel_init,fee_proportional,u32,
msgdata,channel_init,local_msatoshi,amount_msat,
Expand Down
54 changes: 35 additions & 19 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)));
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1967,6 +1967,17 @@ static void peer_in(struct peer *peer, const u8 *msg)
case WIRE_FUNDING_SIGNED:
case WIRE_CHANNEL_REESTABLISH:
case WIRE_CLOSING_SIGNED:
#if EXPERIMENTAL_FEATURES
case WIRE_TX_ADD_INPUT:
case WIRE_TX_ADD_OUTPUT:
case WIRE_TX_REMOVE_INPUT:
case WIRE_TX_REMOVE_OUTPUT:
case WIRE_TX_COMPLETE:
case WIRE_TX_SIGNATURES:
case WIRE_OPEN_CHANNEL2:
case WIRE_ACCEPT_CHANNEL2:
case WIRE_INIT_RBF:
#endif /* EXPERIMENTAL_FEATURES */
break;

/* These are all swallowed by handle_peer_gossip_or_error */
Expand All @@ -1981,6 +1992,9 @@ static void peer_in(struct peer *peer, const u8 *msg)
case WIRE_PING:
case WIRE_PONG:
case WIRE_ERROR:
#if EXPERIMENTAL_FEATURES
case WIRE_BLACKLIST_PODLE:
#endif /* EXPERIMENTAL_FEATURES */
abort();
}

Expand Down Expand Up @@ -2107,7 +2121,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));
Expand Down Expand Up @@ -2812,7 +2826,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:
Expand Down Expand Up @@ -3067,17 +3081,17 @@ 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;
u8 *sigs_msg;
const u8 *msg;
struct fee_states *fee_states;
u32 minimum_depth;
struct secret last_remote_per_commit_secret;
secp256k1_ecdsa_signature *remote_ann_node_sig;
secp256k1_ecdsa_signature *remote_ann_bitcoin_sig;
bool option_static_remotekey;
bool option_static_remotekey, local_funded;
#if !DEVELOPER
bool dev_fail_process_onionpacket; /* Ignored */
#endif
Expand All @@ -3102,7 +3116,8 @@ static void init_channel(struct peer *peer)
&points[REMOTE],
&peer->remote_per_commit,
&peer->old_remote_per_commit,
&funder,
&opener,
&local_funded,
&peer->fee_base,
&peer->fee_per_satoshi,
&local_msat,
Expand All @@ -3127,7 +3142,7 @@ static void init_channel(struct peer *peer)
&peer->shutdown_sent[REMOTE],
&peer->final_scriptpubkey,
&peer->channel_flags,
&funding_signed,
&sigs_msg,
&peer->announce_depth_reached,
&last_remote_per_commit_secret,
&peer->their_features,
Expand All @@ -3148,7 +3163,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,
Expand Down Expand Up @@ -3197,7 +3212,8 @@ static void init_channel(struct peer *peer)
&funding_pubkey[LOCAL],
&funding_pubkey[REMOTE],
option_static_remotekey,
funder);
local_funded,
opener);

if (!channel_force_htlcs(peer->channel,
cast_const2(const struct existing_htlc **, htlcs)))
Expand All @@ -3211,7 +3227,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 */
Expand All @@ -3221,9 +3237,9 @@ static void init_channel(struct peer *peer)
if (reconnected)
peer_reconnect(peer, &last_remote_per_commit_secret);

/* If we have a funding_signed message, send that immediately */
if (funding_signed)
sync_crypto_write(peer->pps, take(funding_signed));
/* If we have a final sigs message, send that immediately */
if (sigs_msg)
sync_crypto_write(peer->pps, take(sigs_msg));

/* Reenable channel */
channel_announcement_negotiate(peer);
Expand Down
4 changes: 2 additions & 2 deletions channeld/commit_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions channeld/commit_tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
Loading