whitespace changes, 80 chars etc
This commit is contained in:
parent
01e37d61e8
commit
0bb483f9b1
|
@ -95,19 +95,21 @@ static void record_channel_open(struct channel *channel)
|
||||||
type_to_string(tmpctx, struct amount_sat,
|
type_to_string(tmpctx, struct amount_sat,
|
||||||
&channel->funding));
|
&channel->funding));
|
||||||
|
|
||||||
/* if we pushed sats, we should decrement that from the channel balance */
|
/* if we pushed sats, we should decrement that
|
||||||
|
* from the channel balance */
|
||||||
if (amount_msat_greater(channel->push, AMOUNT_MSAT(0))) {
|
if (amount_msat_greater(channel->push, AMOUNT_MSAT(0))) {
|
||||||
mvt = new_coin_pushed(ctx, type_to_string(tmpctx,
|
mvt = new_coin_pushed(ctx,
|
||||||
struct channel_id,
|
type_to_string(tmpctx,
|
||||||
&channel->cid),
|
struct channel_id,
|
||||||
|
&channel->cid),
|
||||||
&channel->funding_txid,
|
&channel->funding_txid,
|
||||||
blockheight, channel->push);
|
blockheight, channel->push);
|
||||||
notify_chain_mvt(channel->peer->ld, mvt);
|
notify_chain_mvt(channel->peer->ld, mvt);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* we're not the funder, we record our 'opening balance' anyway
|
/* we're not the funder, we record our 'opening balance'
|
||||||
* (there's a small chance we were pushed some satoshis, otherwise
|
* anyway (there's a small chance we were pushed some
|
||||||
* it's zero) */
|
* satoshis, otherwise it's zero) */
|
||||||
channel_open_amt = channel->our_msat;
|
channel_open_amt = channel->our_msat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +315,9 @@ static void forget(struct channel *channel)
|
||||||
|
|
||||||
struct json_stream *response;
|
struct json_stream *response;
|
||||||
response = json_stream_success(forgets[i]);
|
response = json_stream_success(forgets[i]);
|
||||||
json_add_string(response, "cancelled", "Channel open canceled by RPC(after fundchannel_complete)");
|
json_add_string(response, "cancelled",
|
||||||
|
"Channel open canceled by RPC(after"
|
||||||
|
" fundchannel_complete)");
|
||||||
was_pending(command_success(forgets[i], response));
|
was_pending(command_success(forgets[i], response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,10 +512,13 @@ void peer_start_channeld(struct channel *channel,
|
||||||
if (ld->config.ignore_fee_limits)
|
if (ld->config.ignore_fee_limits)
|
||||||
log_debug(channel->log, "Ignoring fee limits!");
|
log_debug(channel->log, "Ignoring fee limits!");
|
||||||
|
|
||||||
if (!wallet_remote_ann_sigs_load(tmpctx, channel->peer->ld->wallet, channel->dbid,
|
if (!wallet_remote_ann_sigs_load(tmpctx, channel->peer->ld->wallet,
|
||||||
&remote_ann_node_sig, &remote_ann_bitcoin_sig)) {
|
channel->dbid,
|
||||||
|
&remote_ann_node_sig,
|
||||||
|
&remote_ann_bitcoin_sig)) {
|
||||||
channel_internal_error(channel,
|
channel_internal_error(channel,
|
||||||
"Could not load remote announcement signatures");
|
"Could not load remote announcement"
|
||||||
|
" signatures");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,9 +594,9 @@ void peer_start_channeld(struct channel *channel,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool channel_tell_depth(struct lightningd *ld,
|
bool channel_tell_depth(struct lightningd *ld,
|
||||||
struct channel *channel,
|
struct channel *channel,
|
||||||
const struct bitcoin_txid *txid,
|
const struct bitcoin_txid *txid,
|
||||||
u32 depth)
|
u32 depth)
|
||||||
{
|
{
|
||||||
const char *txidstr;
|
const char *txidstr;
|
||||||
|
|
||||||
|
@ -803,23 +810,24 @@ struct command_result *cancel_channel_before_broadcast(struct command *cmd,
|
||||||
"Cannot cancel channel that was "
|
"Cannot cancel channel that was "
|
||||||
"initiated by peer");
|
"initiated by peer");
|
||||||
|
|
||||||
/* Check if we broadcast the transaction. (We store the transaction type into DB
|
/* Check if we broadcast the transaction. (We store the transaction
|
||||||
* before broadcast). */
|
* type into DB before broadcast). */
|
||||||
enum wallet_tx_type type;
|
enum wallet_tx_type type;
|
||||||
if (wallet_transaction_type(cmd->ld->wallet,
|
if (wallet_transaction_type(cmd->ld->wallet,
|
||||||
&cancel_channel->funding_txid,
|
&cancel_channel->funding_txid,
|
||||||
&type))
|
&type))
|
||||||
return command_fail(cmd, FUNDING_CANCEL_NOT_SAFE,
|
return command_fail(cmd, FUNDING_CANCEL_NOT_SAFE,
|
||||||
"Has the funding transaction been broadcast? "
|
"Has the funding transaction been"
|
||||||
"Please use `close` or `dev-fail` instead.");
|
" broadcast? Please use `close` or"
|
||||||
|
" `dev-fail` instead.");
|
||||||
|
|
||||||
if (channel_has_htlc_out(cancel_channel) ||
|
if (channel_has_htlc_out(cancel_channel) ||
|
||||||
channel_has_htlc_in(cancel_channel)) {
|
channel_has_htlc_in(cancel_channel)) {
|
||||||
return command_fail(cmd, FUNDING_CANCEL_NOT_SAFE,
|
return command_fail(cmd, FUNDING_CANCEL_NOT_SAFE,
|
||||||
"This channel has HTLCs attached and it is "
|
"This channel has HTLCs attached and it"
|
||||||
"not safe to cancel. Has the funding transaction "
|
" is not safe to cancel. Has the funding"
|
||||||
"been broadcast? Please use `close` or `dev-fail` "
|
" transaction been broadcast? Please use"
|
||||||
"instead.");
|
" `close` or `dev-fail` instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
tal_arr_expand(&cancel_channel->forgets, cmd);
|
tal_arr_expand(&cancel_channel->forgets, cmd);
|
||||||
|
@ -827,7 +835,8 @@ struct command_result *cancel_channel_before_broadcast(struct command *cmd,
|
||||||
/* Check if the transaction is onchain. */
|
/* Check if the transaction is onchain. */
|
||||||
/* Note: The above check and this check can't completely ensure that
|
/* Note: The above check and this check can't completely ensure that
|
||||||
* the funding transaction isn't broadcast. We can't know if the funding
|
* the funding transaction isn't broadcast. We can't know if the funding
|
||||||
* is broadcast by external wallet and the transaction hasn't been onchain. */
|
* is broadcast by external wallet and the transaction hasn't
|
||||||
|
* been onchain. */
|
||||||
bitcoind_getutxout(cmd->ld->topology->bitcoind,
|
bitcoind_getutxout(cmd->ld->topology->bitcoind,
|
||||||
&cancel_channel->funding_txid,
|
&cancel_channel->funding_txid,
|
||||||
cancel_channel->funding_outnum,
|
cancel_channel->funding_outnum,
|
||||||
|
@ -864,9 +873,10 @@ static struct command_result *json_dev_feerate(struct command *cmd,
|
||||||
return command_fail(cmd, LIGHTNINGD, "Peer bad state");
|
return command_fail(cmd, LIGHTNINGD, "Peer bad state");
|
||||||
|
|
||||||
msg = towire_channeld_feerates(NULL, *feerate,
|
msg = towire_channeld_feerates(NULL, *feerate,
|
||||||
feerate_min(cmd->ld, NULL),
|
feerate_min(cmd->ld, NULL),
|
||||||
feerate_max(cmd->ld, NULL),
|
feerate_max(cmd->ld, NULL),
|
||||||
try_get_feerate(cmd->ld->topology, FEERATE_PENALTY));
|
try_get_feerate(cmd->ld->topology,
|
||||||
|
FEERATE_PENALTY));
|
||||||
subd_send_msg(channel->owner, take(msg));
|
subd_send_msg(channel->owner, take(msg));
|
||||||
|
|
||||||
response = json_stream_success(cmd);
|
response = json_stream_success(cmd);
|
||||||
|
|
|
@ -448,8 +448,9 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dualopend dies? Remove dualopend ptr from payload */
|
/* dualopend dies? Remove dualopend ptr from payload */
|
||||||
static void openchannel2_psbt_remove_dualopend(struct subd *dualopend,
|
static void
|
||||||
struct openchannel2_psbt_payload *payload)
|
openchannel2_psbt_remove_dualopend(struct subd *dualopend,
|
||||||
|
struct openchannel2_psbt_payload *payload)
|
||||||
{
|
{
|
||||||
assert(payload->dualopend == dualopend);
|
assert(payload->dualopend == dualopend);
|
||||||
payload->dualopend = NULL;
|
payload->dualopend = NULL;
|
||||||
|
@ -776,7 +777,8 @@ static void accepter_commit_received(struct subd *dualopend,
|
||||||
payload->ld = ld;
|
payload->ld = ld;
|
||||||
|
|
||||||
if (peer_active_channel(uc->peer)) {
|
if (peer_active_channel(uc->peer)) {
|
||||||
uncommitted_channel_disconnect(uc, LOG_BROKEN, "already have active channel");
|
uncommitted_channel_disconnect(uc, LOG_BROKEN,
|
||||||
|
"already have active channel");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,12 +802,14 @@ static void accepter_commit_received(struct subd *dualopend,
|
||||||
remote_upfront_shutdown_script);
|
remote_upfront_shutdown_script);
|
||||||
|
|
||||||
if (!payload->rcvd->channel) {
|
if (!payload->rcvd->channel) {
|
||||||
uncommitted_channel_disconnect(uc, LOG_BROKEN, "commit channel failed");
|
uncommitted_channel_disconnect(uc, LOG_BROKEN,
|
||||||
|
"commit channel failed");
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pbase)
|
if (pbase)
|
||||||
wallet_penalty_base_add(ld->wallet, payload->rcvd->channel->dbid,
|
wallet_penalty_base_add(ld->wallet,
|
||||||
|
payload->rcvd->channel->dbid,
|
||||||
pbase);
|
pbase);
|
||||||
|
|
||||||
/* dualopend is going away! */
|
/* dualopend is going away! */
|
||||||
|
@ -1176,10 +1180,11 @@ static void peer_tx_sigs_msg(struct subd *dualopend,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct command_result *json_openchannel_signed(struct command *cmd,
|
static struct command_result *
|
||||||
const char *buffer,
|
json_openchannel_signed(struct command *cmd,
|
||||||
const jsmntok_t *obj UNNEEDED,
|
const char *buffer,
|
||||||
const jsmntok_t *params)
|
const jsmntok_t *obj UNNEEDED,
|
||||||
|
const jsmntok_t *params)
|
||||||
{
|
{
|
||||||
struct wally_psbt *psbt;
|
struct wally_psbt *psbt;
|
||||||
const struct wally_tx *wtx;
|
const struct wally_tx *wtx;
|
||||||
|
|
|
@ -313,8 +313,9 @@ static void set_reserve(struct state *state, struct amount_sat funding_total)
|
||||||
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
||||||
*
|
*
|
||||||
* The channel reserve is fixed at 1% of the total channel balance
|
* The channel reserve is fixed at 1% of the total channel balance
|
||||||
* rounded down (sum of `funding_satoshis` from `open_channel2` and `accept_channel2`)
|
* rounded down (sum of `funding_satoshis` from `open_channel2`
|
||||||
* or the `dust_limit_satoshis`, whichever is greater.
|
* and `accept_channel2`) or the `dust_limit_satoshis`, whichever
|
||||||
|
* is greater.
|
||||||
*/
|
*/
|
||||||
reserve = amount_sat_div(funding_total, 100);
|
reserve = amount_sat_div(funding_total, 100);
|
||||||
|
|
||||||
|
@ -1610,8 +1611,8 @@ static u8 *accepter_start(struct state *state, const u8 *oc2_msg)
|
||||||
* - if `signature` is incorrect:
|
* - if `signature` is incorrect:
|
||||||
* - MUST fail the channel.
|
* - MUST fail the channel.
|
||||||
*/
|
*/
|
||||||
if (!check_tx_sig(local_commit, 0, NULL, wscript, &state->their_funding_pubkey,
|
if (!check_tx_sig(local_commit, 0, NULL, wscript,
|
||||||
&remote_sig)) {
|
&state->their_funding_pubkey, &remote_sig)) {
|
||||||
/* BOLT #1:
|
/* BOLT #1:
|
||||||
*
|
*
|
||||||
* ### The `error` Message
|
* ### The `error` Message
|
||||||
|
@ -1627,14 +1628,16 @@ static u8 *accepter_start(struct state *state, const u8 *oc2_msg)
|
||||||
* longer read C code. */
|
* longer read C code. */
|
||||||
peer_failed(state->pps,
|
peer_failed(state->pps,
|
||||||
&state->channel_id,
|
&state->channel_id,
|
||||||
"Bad signature %s on tx %s using key %s (funding txid %s, psbt %s)",
|
"Bad signature %s on tx %s using key %s"
|
||||||
|
" (funding txid %s, psbt %s)",
|
||||||
type_to_string(tmpctx, struct bitcoin_signature,
|
type_to_string(tmpctx, struct bitcoin_signature,
|
||||||
&remote_sig),
|
&remote_sig),
|
||||||
type_to_string(tmpctx, struct bitcoin_tx, local_commit),
|
type_to_string(tmpctx, struct bitcoin_tx,
|
||||||
|
local_commit),
|
||||||
type_to_string(tmpctx, struct pubkey,
|
type_to_string(tmpctx, struct pubkey,
|
||||||
&state->their_funding_pubkey),
|
&state->their_funding_pubkey),
|
||||||
/* This is the first place we'd discover the funding tx
|
/* This is the first place we'd discover
|
||||||
* doesn't match up */
|
* the funding tx doesn't match up */
|
||||||
type_to_string(tmpctx, struct bitcoin_txid,
|
type_to_string(tmpctx, struct bitcoin_txid,
|
||||||
&state->funding_txid),
|
&state->funding_txid),
|
||||||
type_to_string(tmpctx, struct wally_psbt,
|
type_to_string(tmpctx, struct wally_psbt,
|
||||||
|
@ -1725,12 +1728,12 @@ static u8 *opener_start(struct state *state, u8 *msg)
|
||||||
u32 feerate_min, feerate_max, feerate_best;
|
u32 feerate_min, feerate_max, feerate_best;
|
||||||
|
|
||||||
if (!fromwire_dualopend_opener_init(state, msg,
|
if (!fromwire_dualopend_opener_init(state, msg,
|
||||||
&psbt,
|
&psbt,
|
||||||
&state->opener_funding,
|
&state->opener_funding,
|
||||||
&state->upfront_shutdown_script[LOCAL],
|
&state->upfront_shutdown_script[LOCAL],
|
||||||
&state->feerate_per_kw_commitment,
|
&state->feerate_per_kw_commitment,
|
||||||
&state->feerate_per_kw_funding,
|
&state->feerate_per_kw_funding,
|
||||||
&channel_flags))
|
&channel_flags))
|
||||||
master_badmsg(WIRE_DUALOPEND_OPENER_INIT, msg);
|
master_badmsg(WIRE_DUALOPEND_OPENER_INIT, msg);
|
||||||
|
|
||||||
state->our_role = TX_INITIATOR;
|
state->our_role = TX_INITIATOR;
|
||||||
|
@ -2080,14 +2083,16 @@ static u8 *opener_start(struct state *state, u8 *msg)
|
||||||
* longer read C code. */
|
* longer read C code. */
|
||||||
peer_failed(state->pps,
|
peer_failed(state->pps,
|
||||||
&state->channel_id,
|
&state->channel_id,
|
||||||
"Bad signature %s on tx %s using key %s (funding txid %s, psbt %s)",
|
"Bad signature %s on tx %s using key %s "
|
||||||
|
"(funding txid %s, psbt %s)",
|
||||||
type_to_string(tmpctx, struct bitcoin_signature,
|
type_to_string(tmpctx, struct bitcoin_signature,
|
||||||
&remote_sig),
|
&remote_sig),
|
||||||
type_to_string(tmpctx, struct bitcoin_tx, local_commit),
|
type_to_string(tmpctx, struct bitcoin_tx,
|
||||||
|
local_commit),
|
||||||
type_to_string(tmpctx, struct pubkey,
|
type_to_string(tmpctx, struct pubkey,
|
||||||
&state->their_funding_pubkey),
|
&state->their_funding_pubkey),
|
||||||
/* This is the first place we'd discover the funding tx
|
/* This is the first place we'd discover the
|
||||||
* doesn't match up */
|
* funding tx doesn't match up */
|
||||||
type_to_string(tmpctx, struct bitcoin_txid,
|
type_to_string(tmpctx, struct bitcoin_txid,
|
||||||
&state->funding_txid),
|
&state->funding_txid),
|
||||||
type_to_string(tmpctx, struct wally_psbt,
|
type_to_string(tmpctx, struct wally_psbt,
|
||||||
|
|
Loading…
Reference in New Issue