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