mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
Remove general shadowed variables.
We shadow local variables in several places: generally, these changes make the code clearer. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
6a7d40f51a
commit
6fe570820e
25 changed files with 92 additions and 99 deletions
|
@ -1270,8 +1270,6 @@ static void send_commit(struct peer *peer)
|
|||
* don't stress things by having more than one feerate change
|
||||
* in-flight! */
|
||||
if (feerate_changes_done(peer->channel->fee_states, false)) {
|
||||
u8 *msg;
|
||||
|
||||
/* BOLT-919 #2:
|
||||
*
|
||||
* A sending node:
|
||||
|
@ -1309,8 +1307,6 @@ static void send_commit(struct peer *peer)
|
|||
if (want_blockheight_update(peer, &our_blockheight)) {
|
||||
if (blockheight_changes_done(peer->channel->blockheight_states,
|
||||
false)) {
|
||||
u8 *msg;
|
||||
|
||||
channel_update_blockheight(peer->channel,
|
||||
our_blockheight);
|
||||
|
||||
|
@ -2442,14 +2438,14 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last)
|
|||
} else
|
||||
tlvs = NULL;
|
||||
#endif
|
||||
u8 *msg = towire_update_add_htlc(NULL, &peer->channel_id,
|
||||
h->id, h->amount,
|
||||
&h->rhash,
|
||||
abs_locktime_to_blocks(
|
||||
&h->expiry),
|
||||
h->routing
|
||||
msg = towire_update_add_htlc(NULL, &peer->channel_id,
|
||||
h->id, h->amount,
|
||||
&h->rhash,
|
||||
abs_locktime_to_blocks(
|
||||
&h->expiry),
|
||||
h->routing
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, tlvs
|
||||
, tlvs
|
||||
#endif
|
||||
);
|
||||
peer_write(peer->pps, take(msg));
|
||||
|
@ -2952,7 +2948,6 @@ skip_tlvs:
|
|||
if (peer->funding_locked[LOCAL]
|
||||
&& peer->next_index[LOCAL] == 1
|
||||
&& next_commitment_number == 1) {
|
||||
u8 *msg;
|
||||
struct tlv_funding_locked_tlvs *tlvs = tlv_funding_locked_tlvs_new(tmpctx);
|
||||
|
||||
status_debug("Retransmitting funding_locked for channel %s",
|
||||
|
|
|
@ -120,7 +120,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
|||
struct amount_sat base_fee;
|
||||
struct amount_msat total_pay;
|
||||
struct bitcoin_tx *tx;
|
||||
size_t i, n, untrimmed;
|
||||
size_t n, untrimmed;
|
||||
/* Is this the lessor ? */
|
||||
enum side lessor = !opener;
|
||||
u32 *cltvs;
|
||||
|
@ -181,7 +181,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
|||
{
|
||||
struct amount_sat out = AMOUNT_SAT(0);
|
||||
bool ok = true;
|
||||
for (i = 0; i < tal_count(htlcs); i++) {
|
||||
for (size_t i = 0; i < tal_count(htlcs); i++) {
|
||||
if (!trim(htlcs[i], feerate_per_kw, dust_limit,
|
||||
option_anchor_outputs, side))
|
||||
ok &= amount_sat_add(&out, out, amount_msat_to_sat_round_down(htlcs[i]->amount));
|
||||
|
@ -215,7 +215,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
|||
* 4. For every offered HTLC, if it is not trimmed, add an
|
||||
* [offered HTLC output](#offered-htlc-outputs).
|
||||
*/
|
||||
for (i = 0; i < tal_count(htlcs); i++) {
|
||||
for (size_t i = 0; i < tal_count(htlcs); i++) {
|
||||
if (htlc_owner(htlcs[i]) != side)
|
||||
continue;
|
||||
if (trim(htlcs[i], feerate_per_kw, dust_limit,
|
||||
|
@ -233,7 +233,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
|
|||
* 5. For every received HTLC, if it is not trimmed, add an
|
||||
* [received HTLC output](#received-htlc-outputs).
|
||||
*/
|
||||
for (i = 0; i < tal_count(htlcs); i++) {
|
||||
for (size_t i = 0; i < tal_count(htlcs); i++) {
|
||||
if (htlc_owner(htlcs[i]) == side)
|
||||
continue;
|
||||
if (trim(htlcs[i], feerate_per_kw, dust_limit,
|
||||
|
|
|
@ -599,7 +599,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
setup_locale();
|
||||
|
||||
int fd, i;
|
||||
int fd;
|
||||
size_t off;
|
||||
const char *method;
|
||||
char *cmd, *resp, *idstr;
|
||||
|
@ -715,7 +715,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (input == KEYWORDS) {
|
||||
tal_append_fmt(&cmd, "{ ");
|
||||
for (i = 2; i < argc; i++) {
|
||||
for (size_t i = 2; i < argc; i++) {
|
||||
const char *eq = strchr(argv[i], '=');
|
||||
|
||||
if (!eq)
|
||||
|
@ -730,7 +730,7 @@ int main(int argc, char *argv[])
|
|||
tal_append_fmt(&cmd, "} }");
|
||||
} else {
|
||||
tal_append_fmt(&cmd, "[ ");
|
||||
for (i = 2; i < argc; i++)
|
||||
for (size_t i = 2; i < argc; i++)
|
||||
add_input(&cmd, argv[i], i, argc);
|
||||
tal_append_fmt(&cmd, "] }");
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ int main(int argc, char *argv[])
|
|||
/* Replace day */
|
||||
tparts[0] = "UTC";
|
||||
/* Now each part should appear. */
|
||||
for (size_t i = 0; tparts[i]; i++)
|
||||
for (i = 0; tparts[i]; i++)
|
||||
assert(strstr(timestring, tparts[i]));
|
||||
assert(offer_period_start(base, n, &recurrence) == secs);
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ int main(int argc, char *argv[])
|
|||
json_for_each_arr(i, t, unblinding_hops) {
|
||||
struct privkey me;
|
||||
struct secret ss;
|
||||
struct pubkey blinding, expected_blinding;
|
||||
struct pubkey blindingpub, expected_blinding;
|
||||
struct pubkey onion_key, next_node;
|
||||
|
||||
assert(json_to_secret(json,
|
||||
|
@ -337,20 +337,20 @@ int main(int argc, char *argv[])
|
|||
mykey = &me;
|
||||
assert(json_to_pubkey(json,
|
||||
json_get_member(json, t, "ephemeral_pubkey"),
|
||||
&blinding));
|
||||
&blindingpub));
|
||||
|
||||
assert(unblind_onion(&blinding, test_ecdh, &onion_key, &ss));
|
||||
assert(unblind_onion(&blindingpub, test_ecdh, &onion_key, &ss));
|
||||
if (i != unblinding_hops->size - 1) {
|
||||
assert(decrypt_enctlv(&blinding, &ss, encrypted_data[i], &next_node, &blinding));
|
||||
assert(decrypt_enctlv(&blindingpub, &ss, encrypted_data[i], &next_node, &blindingpub));
|
||||
assert(json_to_pubkey(json,
|
||||
json_get_member(json, t, "next_ephemeral_pubkey"),
|
||||
&expected_blinding));
|
||||
assert(pubkey_eq(&blinding, &expected_blinding));
|
||||
assert(pubkey_eq(&blindingpub, &expected_blinding));
|
||||
} else {
|
||||
struct secret *path_id;
|
||||
struct pubkey my_id, alias;
|
||||
assert(pubkey_from_privkey(&me, &my_id));
|
||||
assert(decrypt_final_enctlv(tmpctx, &blinding, &ss,
|
||||
assert(decrypt_final_enctlv(tmpctx, &blindingpub, &ss,
|
||||
encrypted_data[i],
|
||||
&my_id, &alias,
|
||||
&path_id));
|
||||
|
|
|
@ -54,7 +54,6 @@ int main(int argc, char *argv[])
|
|||
const char *method;
|
||||
struct bolt11 *b11;
|
||||
struct bolt11_field *extra;
|
||||
size_t i;
|
||||
char *fail, *description = NULL;
|
||||
|
||||
common_setup(argv[0]);
|
||||
|
@ -120,7 +119,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
printf("\n");
|
||||
}
|
||||
for (i = 0; i < tal_count(b11->fallbacks); i++) {
|
||||
for (size_t i = 0; i < tal_count(b11->fallbacks); i++) {
|
||||
struct bitcoin_address pkh;
|
||||
struct ripemd160 sh;
|
||||
struct sha256 wsh;
|
||||
|
@ -148,7 +147,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < tal_count(b11->routes); i++) {
|
||||
for (size_t i = 0; i < tal_count(b11->routes); i++) {
|
||||
printf("route: (node/chanid/fee/expirydelta) ");
|
||||
for (size_t n = 0; n < tal_count(b11->routes[i]); n++) {
|
||||
printf(" %s/%s/%u/%u/%u",
|
||||
|
@ -169,6 +168,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
list_for_each(&b11->extra_fields, extra, list) {
|
||||
char *data = tal_arr(ctx, char, tal_count(extra->data)+1);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < tal_count(extra->data); i++)
|
||||
data[i] = bech32_charset[extra->data[i]];
|
||||
|
|
|
@ -105,8 +105,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
m = tal_dup_arr(f, u8, f + off, be16_to_cpu(len), 0);
|
||||
if (printtlv) {
|
||||
size_t len = tal_bytelen(m);
|
||||
ok &= printtlv("", &m, &len);
|
||||
size_t mlen = tal_bytelen(m);
|
||||
ok &= printtlv("", &m, &mlen);
|
||||
} else {
|
||||
ok &= printwire(m);
|
||||
}
|
||||
|
|
|
@ -170,7 +170,6 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
|||
struct oneshot *timer,
|
||||
char **args)
|
||||
{
|
||||
u8 *msg;
|
||||
int peer_fd = io_conn_fd(conn);
|
||||
struct pollfd pollfd[2];
|
||||
|
||||
|
@ -179,6 +178,7 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
|||
OPTIONAL_FEATURE(OPT_INITIAL_ROUTING_SYNC));
|
||||
|
||||
if (!no_init) {
|
||||
u8 *msg;
|
||||
struct tlv_init_tlvs *tlvs = NULL;
|
||||
if (explicit_network) {
|
||||
tlvs = tlv_init_tlvs_new(NULL);
|
||||
|
|
|
@ -103,10 +103,9 @@ int main(int argc, char *argv[])
|
|||
for (n = gossmap_first_node(map);
|
||||
n;
|
||||
n = gossmap_next_node(map, n)) {
|
||||
struct node_id srcid, dstid;
|
||||
struct node_id srcid;
|
||||
|
||||
gossmap_node_get_id(map, n, &srcid);
|
||||
gossmap_node_get_id(map, dst, &dstid);
|
||||
printf("# %s->%s\n",
|
||||
type_to_string(tmpctx, struct node_id, &srcid),
|
||||
type_to_string(tmpctx, struct node_id, &dstid));
|
||||
|
|
|
@ -785,17 +785,17 @@ u32 gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
|
|||
|
||||
switch (fromwire_peektype(msg)) {
|
||||
case WIRE_GOSSIP_STORE_PRIVATE_CHANNEL: {
|
||||
u8 *chan_ann;
|
||||
u8 *priv_chan_ann;
|
||||
struct amount_sat sat;
|
||||
if (!fromwire_gossip_store_private_channel(msg, msg,
|
||||
&sat,
|
||||
&chan_ann)) {
|
||||
&priv_chan_ann)) {
|
||||
bad = "Bad private_channel";
|
||||
goto badmsg;
|
||||
}
|
||||
|
||||
if (!routing_add_private_channel(rstate, NULL,
|
||||
sat, chan_ann,
|
||||
sat, priv_chan_ann,
|
||||
gs->len)) {
|
||||
bad = "Bad add_private_channel";
|
||||
goto badmsg;
|
||||
|
|
|
@ -1069,9 +1069,9 @@ bool query_channel_range(struct daemon *daemon,
|
|||
struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
enum query_option_flags qflags,
|
||||
void (*cb)(struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
const struct range_query_reply *replies))
|
||||
void (*cb)(struct peer *,
|
||||
u32, u32,
|
||||
const struct range_query_reply *))
|
||||
{
|
||||
u8 *msg;
|
||||
struct tlv_query_channel_range_tlvs *tlvs;
|
||||
|
|
|
@ -40,16 +40,17 @@ bool query_channel_range(struct daemon *daemon,
|
|||
struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
enum query_option_flags qflags,
|
||||
void (*cb)(struct peer *peer,
|
||||
u32 first_blocknum, u32 number_of_blocks,
|
||||
const struct range_query_reply *replies));
|
||||
void (*cb)(struct peer *peer_,
|
||||
u32 first_blocknum_,
|
||||
u32 number_of_blocks_,
|
||||
const struct range_query_reply *replies_));
|
||||
|
||||
/* Ask this peer for info about an array of scids, with optional query_flags */
|
||||
bool query_short_channel_ids(struct daemon *daemon,
|
||||
struct peer *peer,
|
||||
const struct short_channel_id *scids,
|
||||
const u8 *query_flags,
|
||||
void (*cb)(struct peer *peer, bool complete));
|
||||
void (*cb)(struct peer *peer_, bool complete));
|
||||
|
||||
#if DEVELOPER
|
||||
struct io_plan *query_scids_req(struct io_conn *conn,
|
||||
|
|
|
@ -43,16 +43,17 @@ bool query_channel_range(struct daemon *daemon UNNEEDED,
|
|||
struct peer *peer UNNEEDED,
|
||||
u32 first_blocknum UNNEEDED, u32 number_of_blocks UNNEEDED,
|
||||
enum query_option_flags qflags UNNEEDED,
|
||||
void (*cb)(struct peer *peer UNNEEDED,
|
||||
u32 first_blocknum UNNEEDED, u32 number_of_blocks UNNEEDED,
|
||||
const struct range_query_reply *replies))
|
||||
void (*cb)(struct peer *peer_ UNNEEDED,
|
||||
u32 first_blocknum_ UNNEEDED,
|
||||
u32 number_of_blocks_ UNNEEDED,
|
||||
const struct range_query_reply *replies_))
|
||||
{ fprintf(stderr, "query_channel_range called!\n"); abort(); }
|
||||
/* Generated stub for query_short_channel_ids */
|
||||
bool query_short_channel_ids(struct daemon *daemon UNNEEDED,
|
||||
struct peer *peer UNNEEDED,
|
||||
const struct short_channel_id *scids UNNEEDED,
|
||||
const u8 *query_flags UNNEEDED,
|
||||
void (*cb)(struct peer *peer UNNEEDED, bool complete))
|
||||
void (*cb)(struct peer *peer_ UNNEEDED, bool complete))
|
||||
{ fprintf(stderr, "query_short_channel_ids called!\n"); abort(); }
|
||||
/* Generated stub for queue_peer_msg */
|
||||
void queue_peer_msg(struct peer *peer UNNEEDED, const u8 *msg TAKES UNNEEDED)
|
||||
|
|
|
@ -549,9 +549,9 @@ clean:
|
|||
|
||||
void bitcoind_getutxout_(struct bitcoind *bitcoind,
|
||||
const struct bitcoin_outpoint *outpoint,
|
||||
void (*cb)(struct bitcoind *bitcoind,
|
||||
const struct bitcoin_tx_output *txout,
|
||||
void *arg),
|
||||
void (*cb)(struct bitcoind *,
|
||||
const struct bitcoin_tx_output *,
|
||||
void *),
|
||||
void *cb_arg)
|
||||
{
|
||||
struct jsonrpc_request *req;
|
||||
|
|
|
@ -150,9 +150,9 @@ void bitcoind_getrawblockbyheight_(struct bitcoind *bitcoind,
|
|||
|
||||
void bitcoind_getutxout_(struct bitcoind *bitcoind,
|
||||
const struct bitcoin_outpoint *outpoint,
|
||||
void (*cb)(struct bitcoind *bitcoind,
|
||||
const struct bitcoin_tx_output *txout,
|
||||
void *arg),
|
||||
void (*cb)(struct bitcoind *,
|
||||
const struct bitcoin_tx_output *,
|
||||
void *),
|
||||
void *arg);
|
||||
#define bitcoind_getutxout(bitcoind_, outpoint_, cb, arg) \
|
||||
bitcoind_getutxout_((bitcoind_), (outpoint_), \
|
||||
|
|
|
@ -761,7 +761,7 @@ static void remove_tip(struct chain_topology *topo)
|
|||
{
|
||||
struct block *b = topo->tip;
|
||||
struct bitcoin_txid *txs;
|
||||
size_t i, n;
|
||||
size_t n;
|
||||
const struct short_channel_id *removed_scids;
|
||||
|
||||
log_debug(topo->log, "Removing stale block %u: %s",
|
||||
|
@ -780,7 +780,7 @@ static void remove_tip(struct chain_topology *topo)
|
|||
n = tal_count(txs);
|
||||
|
||||
/* Notify that txs are kicked out (their height will be set NULL in db) */
|
||||
for (i = 0; i < n; i++)
|
||||
for (size_t i = 0; i < n; i++)
|
||||
txwatch_fire(topo, &txs[i], 0);
|
||||
|
||||
/* Grab these before we delete block from db */
|
||||
|
@ -795,7 +795,7 @@ static void remove_tip(struct chain_topology *topo)
|
|||
|
||||
/* These no longer exist, so gossipd drops any reference to them just
|
||||
* as if they were spent. */
|
||||
for (size_t i=0; i<tal_count(removed_scids); i++)
|
||||
for (size_t i = 0; i < tal_count(removed_scids); i++)
|
||||
gossipd_notify_spend(topo->bitcoind->ld, &removed_scids[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,13 @@ static void json_add_ptr(struct json_stream *response, const char *name,
|
|||
}
|
||||
|
||||
static size_t add_memdump(struct json_stream *response,
|
||||
const char *name, const tal_t *root,
|
||||
struct command *cmd)
|
||||
const char *fieldname, const tal_t *root,
|
||||
struct command *cmd)
|
||||
{
|
||||
const tal_t *i;
|
||||
size_t cumulative_size = 0;
|
||||
|
||||
json_array_start(response, name);
|
||||
for (i = tal_first(root); i; i = tal_next(i)) {
|
||||
json_array_start(response, fieldname);
|
||||
for (const tal_t *i = tal_first(root); i; i = tal_next(i)) {
|
||||
const char *name = tal_name(i);
|
||||
size_t size = tal_bytelen(i);
|
||||
|
||||
|
@ -176,9 +175,11 @@ static void finish_report(const struct leak_detect *leaks)
|
|||
json_object_end(response);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < tal_count(leaks->leakers); i++) {
|
||||
for (size_t num_leakers = 0;
|
||||
num_leakers < tal_count(leaks->leakers);
|
||||
num_leakers++) {
|
||||
json_object_start(response, NULL);
|
||||
json_add_string(response, "subdaemon", leaks->leakers[i]);
|
||||
json_add_string(response, "subdaemon", leaks->leakers[num_leakers]);
|
||||
json_object_end(response);
|
||||
}
|
||||
json_array_end(response);
|
||||
|
|
|
@ -704,10 +704,10 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
|
|||
if (!feerates[i]) {
|
||||
/* We have at least one data point: the last tx's feerate. */
|
||||
struct amount_sat fee = channel->funding_sats;
|
||||
for (size_t i = 0;
|
||||
i < channel->last_tx->wtx->num_outputs; i++) {
|
||||
for (size_t j = 0;
|
||||
j < channel->last_tx->wtx->num_outputs; j++) {
|
||||
struct amount_asset asset =
|
||||
bitcoin_tx_output_get_amount(channel->last_tx, i);
|
||||
bitcoin_tx_output_get_amount(channel->last_tx, j);
|
||||
struct amount_sat amt;
|
||||
assert(amount_asset_is_main(&asset));
|
||||
amt = amount_asset_to_sat(&asset);
|
||||
|
|
|
@ -379,8 +379,8 @@ void plugin_hook_db_sync(struct db *db)
|
|||
db_data_version_get(db));
|
||||
|
||||
json_array_start(req->stream, "writes");
|
||||
for (size_t i = 0; i < tal_count(changes); i++)
|
||||
json_add_string(req->stream, NULL, changes[i]);
|
||||
for (size_t j = 0; j < tal_count(changes); j++)
|
||||
json_add_string(req->stream, NULL, changes[j]);
|
||||
json_array_end(req->stream);
|
||||
jsonrpc_request_end(req);
|
||||
|
||||
|
@ -489,8 +489,7 @@ static struct plugin **plugin_hook_make_ordered(const tal_t *ctx,
|
|||
/* Add edges. */
|
||||
for (size_t i = 0; i < tal_count(graph); i++) {
|
||||
for (size_t j = 0; j < tal_count(graph[i].hook->before); j++) {
|
||||
struct hook_node *n = find_hook(graph,
|
||||
graph[i].hook->before[j]);
|
||||
n = find_hook(graph, graph[i].hook->before[j]);
|
||||
if (!n) {
|
||||
/* This is useful for typos! */
|
||||
log_debug(graph[i].hook->plugin->log,
|
||||
|
@ -503,8 +502,7 @@ static struct plugin **plugin_hook_make_ordered(const tal_t *ctx,
|
|||
n->num_incoming++;
|
||||
}
|
||||
for (size_t j = 0; j < tal_count(graph[i].hook->after); j++) {
|
||||
struct hook_node *n = find_hook(graph,
|
||||
graph[i].hook->after[j]);
|
||||
n = find_hook(graph, graph[i].hook->after[j]);
|
||||
if (!n) {
|
||||
/* This is useful for typos! */
|
||||
log_debug(graph[i].hook->plugin->log,
|
||||
|
|
|
@ -135,7 +135,6 @@ static void listnodes_done(const char *buffer,
|
|||
t = json_get_member(buffer, t, "nodes");
|
||||
|
||||
if (!deprecated_apis && (!t || t->size == 0)) {
|
||||
struct json_stream *response;
|
||||
response = json_stream_fail(can->cmd, SIGNMESSAGE_PUBKEY_NOT_FOUND,
|
||||
"pubkey not found in the graph");
|
||||
json_add_node_id(response, "claimed_key", &can->id);
|
||||
|
|
|
@ -326,7 +326,7 @@ static void channel_hints_update(struct payment *p,
|
|||
u16 *htlc_budget)
|
||||
{
|
||||
struct payment *root = payment_root(p);
|
||||
struct channel_hint hint;
|
||||
struct channel_hint newhint;
|
||||
|
||||
/* If the channel is marked as enabled it must have an estimate. */
|
||||
assert(!enabled || estimated_capacity != NULL);
|
||||
|
@ -372,25 +372,25 @@ static void channel_hints_update(struct payment *p,
|
|||
}
|
||||
|
||||
/* No hint found, create one. */
|
||||
hint.enabled = enabled;
|
||||
hint.scid.scid = scid;
|
||||
hint.scid.dir = direction;
|
||||
hint.local = local;
|
||||
newhint.enabled = enabled;
|
||||
newhint.scid.scid = scid;
|
||||
newhint.scid.dir = direction;
|
||||
newhint.local = local;
|
||||
if (estimated_capacity != NULL)
|
||||
hint.estimated_capacity = *estimated_capacity;
|
||||
newhint.estimated_capacity = *estimated_capacity;
|
||||
|
||||
if (htlc_budget != NULL)
|
||||
hint.htlc_budget = *htlc_budget;
|
||||
newhint.htlc_budget = *htlc_budget;
|
||||
|
||||
tal_arr_expand(&root->channel_hints, hint);
|
||||
tal_arr_expand(&root->channel_hints, newhint);
|
||||
|
||||
paymod_log(
|
||||
p, LOG_DBG,
|
||||
"Added a channel hint for %s: enabled %s, estimated capacity %s",
|
||||
type_to_string(tmpctx, struct short_channel_id_dir, &hint.scid),
|
||||
hint.enabled ? "true" : "false",
|
||||
type_to_string(tmpctx, struct short_channel_id_dir, &newhint.scid),
|
||||
newhint.enabled ? "true" : "false",
|
||||
type_to_string(tmpctx, struct amount_msat,
|
||||
&hint.estimated_capacity));
|
||||
&newhint.estimated_capacity));
|
||||
}
|
||||
|
||||
static void payment_exclude_most_expensive(struct payment *p)
|
||||
|
|
|
@ -1021,15 +1021,15 @@ static struct command_result *handle_init(struct command *cmd,
|
|||
opttok = json_get_member(buf, params, "options");
|
||||
json_for_each_obj(i, t, opttok) {
|
||||
char *opt = json_strdup(NULL, buf, t);
|
||||
for (size_t i = 0; i < tal_count(p->opts); i++) {
|
||||
for (size_t optnum = 0; optnum < tal_count(p->opts); optnum++) {
|
||||
char *problem;
|
||||
if (!streq(p->opts[i].name, opt))
|
||||
if (!streq(p->opts[optnum].name, opt))
|
||||
continue;
|
||||
problem = p->opts[i].handle(json_strdup(opt, buf, t+1),
|
||||
p->opts[i].arg);
|
||||
problem = p->opts[optnum].handle(json_strdup(opt, buf, t+1),
|
||||
p->opts[optnum].arg);
|
||||
if (problem)
|
||||
plugin_err(p, "option '%s': %s",
|
||||
p->opts[i].name, problem);
|
||||
p->opts[optnum].name, problem);
|
||||
break;
|
||||
}
|
||||
tal_free(opt);
|
||||
|
|
|
@ -506,7 +506,7 @@ static struct command_result *listsendpays_done(struct command *cmd,
|
|||
|
||||
ret = jsonrpc_stream_success(cmd);
|
||||
json_array_start(ret, "pays");
|
||||
for (size_t i = 0; i < tal_count(order); i++) {
|
||||
for (i = 0; i < tal_count(order); i++) {
|
||||
pm = pay_map_get(&pay_map, &order[i]);
|
||||
assert(pm != NULL);
|
||||
add_new_entry(ret, buf, pm);
|
||||
|
|
|
@ -177,7 +177,7 @@ static struct command_result *signpsbt_done(struct command *cmd,
|
|||
static struct command_result *finish_txprepare(struct command *cmd,
|
||||
struct txprepare *txp)
|
||||
{
|
||||
struct json_stream *out;
|
||||
struct json_stream *js;
|
||||
struct unreleased_tx *utx;
|
||||
|
||||
/* Add the outputs they gave us */
|
||||
|
@ -225,11 +225,11 @@ static struct command_result *finish_txprepare(struct command *cmd,
|
|||
}
|
||||
|
||||
list_add(&unreleased_txs, &utx->list);
|
||||
out = jsonrpc_stream_success(cmd);
|
||||
json_add_hex_talarr(out, "unsigned_tx", linearize_wtx(tmpctx, utx->tx));
|
||||
json_add_txid(out, "txid", &utx->txid);
|
||||
json_add_psbt(out, "psbt", utx->psbt);
|
||||
return command_finished(cmd, out);
|
||||
js = jsonrpc_stream_success(cmd);
|
||||
json_add_hex_talarr(js, "unsigned_tx", linearize_wtx(tmpctx, utx->tx));
|
||||
json_add_txid(js, "txid", &utx->txid);
|
||||
json_add_psbt(js, "psbt", utx->psbt);
|
||||
return command_finished(cmd, js);
|
||||
}
|
||||
|
||||
/* newaddr has given us a change address. */
|
||||
|
|
|
@ -914,8 +914,7 @@ static bool db_migrate(struct lightningd *ld, struct db *db,
|
|||
while (current < available) {
|
||||
current++;
|
||||
if (dbmigrations[current].sql) {
|
||||
struct db_stmt *stmt =
|
||||
db_prepare_v2(db, dbmigrations[current].sql);
|
||||
stmt = db_prepare_v2(db, dbmigrations[current].sql);
|
||||
db_exec_prepared_v2(stmt);
|
||||
tal_free(stmt);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue