mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
lightningd/peer_control: save funder side in struct peer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
be9bb5f9cb
commit
93849b1e02
2 changed files with 15 additions and 6 deletions
|
@ -1414,7 +1414,7 @@ static bool peer_start_channeld_hsmfd(struct subd *hsm, const u8 *resp,
|
|||
}
|
||||
|
||||
/* opening is done, start lightningd_channel for peer. */
|
||||
static void peer_start_channeld(struct peer *peer, enum side funder,
|
||||
static void peer_start_channeld(struct peer *peer,
|
||||
const struct channel_config *their_config,
|
||||
const struct crypto_state *crypto_state,
|
||||
const secp256k1_ecdsa_signature *commit_sig,
|
||||
|
@ -1432,8 +1432,8 @@ static void peer_start_channeld(struct peer *peer, enum side funder,
|
|||
|
||||
/* Now we can consider balance set. */
|
||||
peer->balance = tal_arr(peer, u64, NUM_SIDES);
|
||||
peer->balance[funder] = peer->funding_satoshi * 1000 - peer->push_msat;
|
||||
peer->balance[!funder] = peer->push_msat;
|
||||
peer->balance[peer->funder] = peer->funding_satoshi * 1000 - peer->push_msat;
|
||||
peer->balance[!peer->funder] = peer->push_msat;
|
||||
|
||||
cds->peer = peer;
|
||||
/* Prepare init message now while we have access to all the data. */
|
||||
|
@ -1449,7 +1449,7 @@ static void peer_start_channeld(struct peer *peer, enum side funder,
|
|||
&theirbase->payment,
|
||||
&theirbase->delayed_payment,
|
||||
their_per_commit_point,
|
||||
funder == LOCAL,
|
||||
peer->funder == LOCAL,
|
||||
cfg->fee_base,
|
||||
cfg->fee_per_satoshi,
|
||||
peer->funding_satoshi,
|
||||
|
@ -1514,7 +1514,7 @@ static bool opening_release_tx(struct subd *opening, const u8 *resp,
|
|||
opening_got_hsm_funding_sig, fc);
|
||||
|
||||
/* Start normal channel daemon. */
|
||||
peer_start_channeld(fc->peer, LOCAL,
|
||||
peer_start_channeld(fc->peer,
|
||||
&their_config, &crypto_state, &commit_sig,
|
||||
&fc->remote_fundingkey, &theirbase,
|
||||
&their_per_commit_point);
|
||||
|
@ -1592,7 +1592,7 @@ static bool opening_accept_finish_response(struct subd *opening,
|
|||
}
|
||||
|
||||
/* On to normal operation! */
|
||||
peer_start_channeld(peer, REMOTE, &their_config, &crypto_state,
|
||||
peer_start_channeld(peer, &their_config, &crypto_state,
|
||||
&first_commit_sig, &remote_fundingkey, &theirbase,
|
||||
&their_per_commit_point);
|
||||
|
||||
|
@ -1699,6 +1699,9 @@ void peer_accept_open(struct peer *peer,
|
|||
/* We handed off peer fd */
|
||||
peer->fd = -1;
|
||||
|
||||
/* They will open channel. */
|
||||
peer->funder = REMOTE;
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sender SHOULD set `minimum-depth` to an amount where
|
||||
|
@ -1771,6 +1774,8 @@ static bool gossip_peer_released(struct subd *gossip,
|
|||
/* They took our fd. */
|
||||
fc->peer->fd = -1;
|
||||
|
||||
/* We will fund channel */
|
||||
fc->peer->funder = LOCAL;
|
||||
channel_config(ld, &fc->peer->our_config,
|
||||
&max_to_self_delay, &max_minimum_depth,
|
||||
&min_effective_htlc_capacity_msat);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "config.h"
|
||||
#include <ccan/compiler/compiler.h>
|
||||
#include <ccan/list/list.h>
|
||||
#include <daemon/htlc.h>
|
||||
#include <daemon/json.h>
|
||||
#include <daemon/netaddr.h>
|
||||
#include <lightningd/channel_config.h>
|
||||
|
@ -18,6 +19,9 @@ struct peer {
|
|||
/* Unique ID (works before we know their pubkey) */
|
||||
u64 unique_id;
|
||||
|
||||
/* Which side offered channel? */
|
||||
enum side funder;
|
||||
|
||||
/* Inside ld->peers. */
|
||||
struct list_node list;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue