|
|
@ -31,6 +31,7 @@ |
|
|
|
#include <common/overflows.h> |
|
|
|
#include <common/peer_billboard.h> |
|
|
|
#include <common/peer_failed.h> |
|
|
|
#include <common/penalty_base.h> |
|
|
|
#include <common/pseudorand.h> |
|
|
|
#include <common/read_peer_msg.h> |
|
|
|
#include <common/status.h> |
|
|
@ -659,7 +660,8 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags) |
|
|
|
static bool funder_finalize_channel_setup(struct state *state, |
|
|
|
struct amount_msat local_msat, |
|
|
|
struct bitcoin_signature *sig, |
|
|
|
struct bitcoin_tx **tx) |
|
|
|
struct bitcoin_tx **tx, |
|
|
|
struct penalty_base **pbase) |
|
|
|
{ |
|
|
|
u8 *msg; |
|
|
|
struct channel_id id_in; |
|
|
@ -720,6 +722,11 @@ static bool funder_finalize_channel_setup(struct state *state, |
|
|
|
goto fail; |
|
|
|
} |
|
|
|
|
|
|
|
if (direct_outputs[LOCAL]) |
|
|
|
*pbase = penalty_base_new(state, 0, *tx, direct_outputs[LOCAL]); |
|
|
|
else |
|
|
|
*pbase = NULL; |
|
|
|
|
|
|
|
/* We ask the HSM to sign their commitment transaction for us: it knows
|
|
|
|
* our funding key, it just needs the remote funding key to create the |
|
|
|
* witness script. It also needs the amount of the funding output, |
|
|
@ -850,9 +857,11 @@ fail: |
|
|
|
|
|
|
|
static u8 *funder_channel_complete(struct state *state) |
|
|
|
{ |
|
|
|
/* Remote commitment tx */ |
|
|
|
struct bitcoin_tx *tx; |
|
|
|
struct bitcoin_signature sig; |
|
|
|
struct amount_msat local_msat; |
|
|
|
struct penalty_base *pbase; |
|
|
|
|
|
|
|
/* Update the billboard about what we're doing*/ |
|
|
|
peer_billboard(false, |
|
|
@ -869,12 +878,14 @@ static u8 *funder_channel_complete(struct state *state) |
|
|
|
type_to_string(tmpctx, struct amount_sat, |
|
|
|
&state->funding)); |
|
|
|
|
|
|
|
if (!funder_finalize_channel_setup(state, local_msat, &sig, &tx)) |
|
|
|
if (!funder_finalize_channel_setup(state, local_msat, &sig, &tx, |
|
|
|
&pbase)) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
return towire_opening_funder_reply(state, |
|
|
|
&state->remoteconf, |
|
|
|
tx, |
|
|
|
pbase, |
|
|
|
&sig, |
|
|
|
state->pps, |
|
|
|
&state->their_points.revocation, |
|
|
@ -905,6 +916,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) |
|
|
|
u8 channel_flags; |
|
|
|
char* err_reason; |
|
|
|
struct wally_tx_output *direct_outputs[NUM_SIDES]; |
|
|
|
struct penalty_base *pbase; |
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
|
* |
|
|
@ -1274,9 +1286,16 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) |
|
|
|
assert(sig.sighash_type == SIGHASH_ALL); |
|
|
|
msg = towire_funding_signed(state, &state->channel_id, &sig.s); |
|
|
|
|
|
|
|
if (direct_outputs[LOCAL] != NULL) |
|
|
|
pbase = penalty_base_new(tmpctx, 0, remote_commit, |
|
|
|
direct_outputs[LOCAL]); |
|
|
|
else |
|
|
|
pbase = NULL; |
|
|
|
|
|
|
|
return towire_opening_fundee(state, |
|
|
|
&state->remoteconf, |
|
|
|
local_commit, |
|
|
|
pbase, |
|
|
|
&theirsig, |
|
|
|
state->pps, |
|
|
|
&theirs.revocation, |
|
|
|