mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
wallet: fix parameter order to hand const tal_t *ctx
first.
This is the convention everywhere else: allocation ctx comes first, any other context comes second. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e0e879c003
commit
77936cedda
@ -930,7 +930,7 @@ static void topo_update_spends(struct chain_topology *topo, struct block *b)
|
||||
|
||||
bitcoin_tx_input_get_outpoint(tx, j, &outpoint);
|
||||
|
||||
if (wallet_outpoint_spend(topo->ld->wallet, tmpctx,
|
||||
if (wallet_outpoint_spend(tmpctx, topo->ld->wallet,
|
||||
b->height, &outpoint))
|
||||
record_wallet_spend(topo->ld, &outpoint,
|
||||
&b->txids[i], b->height);
|
||||
|
@ -160,7 +160,7 @@ static void listforwardings_add_forwardings(struct json_stream *response,
|
||||
{
|
||||
const struct forwarding *forwardings;
|
||||
|
||||
forwardings = wallet_forwarded_payments_get(wallet, tmpctx, status, chan_in, chan_out, listindex, liststart, listlimit);
|
||||
forwardings = wallet_forwarded_payments_get(tmpctx, wallet, status, chan_in, chan_out, listindex, liststart, listlimit);
|
||||
|
||||
json_array_start(response, "forwards");
|
||||
for (size_t i=0; i<tal_count(forwardings); i++) {
|
||||
|
@ -83,35 +83,36 @@ static void got_filteredblock(struct bitcoind *bitcoind,
|
||||
|
||||
static void get_txout(struct subd *gossip, const u8 *msg)
|
||||
{
|
||||
struct short_channel_id *scid = tal(gossip, struct short_channel_id);
|
||||
struct short_channel_id scid;
|
||||
struct outpoint *op;
|
||||
u32 blockheight;
|
||||
struct chain_topology *topo = gossip->ld->topology;
|
||||
|
||||
if (!fromwire_gossipd_get_txout(msg, scid))
|
||||
if (!fromwire_gossipd_get_txout(msg, &scid))
|
||||
fatal("Gossip gave bad GOSSIP_GET_TXOUT message %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
/* FIXME: Block less than 6 deep? */
|
||||
blockheight = short_channel_id_blocknum(scid);
|
||||
|
||||
op = wallet_outpoint_for_scid(gossip->ld->wallet, scid, scid);
|
||||
blockheight = short_channel_id_blocknum(&scid);
|
||||
|
||||
op = wallet_outpoint_for_scid(tmpctx, gossip->ld->wallet, &scid);
|
||||
if (op) {
|
||||
subd_send_msg(gossip,
|
||||
towire_gossipd_get_txout_reply(
|
||||
scid, scid, op->sat, op->scriptpubkey));
|
||||
tal_free(scid);
|
||||
take(towire_gossipd_get_txout_reply(
|
||||
NULL, &scid, op->sat, op->scriptpubkey)));
|
||||
} else if (wallet_have_block(gossip->ld->wallet, blockheight)) {
|
||||
/* We should have known about this outpoint since its header
|
||||
* is in the DB. The fact that we don't means that this is
|
||||
* either a spent outpoint or an invalid one. Return a
|
||||
* failure. */
|
||||
subd_send_msg(gossip, take(towire_gossipd_get_txout_reply(
|
||||
NULL, scid, AMOUNT_SAT(0), NULL)));
|
||||
tal_free(scid);
|
||||
NULL, &scid, AMOUNT_SAT(0), NULL)));
|
||||
} else {
|
||||
bitcoind_getfilteredblock(topo->bitcoind, short_channel_id_blocknum(scid), got_filteredblock, scid);
|
||||
/* Make a pointer of a copy of scid here, for got_filteredblock */
|
||||
bitcoind_getfilteredblock(topo->bitcoind,
|
||||
short_channel_id_blocknum(&scid),
|
||||
got_filteredblock,
|
||||
tal_dup(gossip, struct short_channel_id, &scid));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1642,13 +1642,13 @@ void onchaind_replay_channels(struct lightningd *ld)
|
||||
struct channel *chan;
|
||||
|
||||
db_begin_transaction(ld->wallet->db);
|
||||
onchaind_ids = wallet_onchaind_channels(ld->wallet, ld);
|
||||
onchaind_ids = wallet_onchaind_channels(tmpctx, ld->wallet);
|
||||
|
||||
for (size_t i = 0; i < tal_count(onchaind_ids); i++) {
|
||||
log_info(ld->log, "Restarting onchaind for channel %d",
|
||||
onchaind_ids[i]);
|
||||
|
||||
txs = wallet_channeltxs_get(ld->wallet, onchaind_ids,
|
||||
txs = wallet_channeltxs_get(onchaind_ids, ld->wallet,
|
||||
onchaind_ids[i]);
|
||||
chan = channel_by_dbid(ld, onchaind_ids[i]);
|
||||
|
||||
@ -1674,7 +1674,6 @@ void onchaind_replay_channels(struct lightningd *ld)
|
||||
}
|
||||
tal_free(txs);
|
||||
}
|
||||
tal_free(onchaind_ids);
|
||||
|
||||
db_commit_transaction(ld->wallet->db);
|
||||
}
|
||||
|
@ -1156,7 +1156,7 @@ static void json_add_channel(struct lightningd *ld,
|
||||
json_add_num(response, "max_accepted_htlcs",
|
||||
channel->our_config.max_accepted_htlcs);
|
||||
|
||||
state_changes = wallet_state_change_get(ld->wallet, tmpctx, channel->dbid);
|
||||
state_changes = wallet_state_change_get(tmpctx, ld->wallet, channel->dbid);
|
||||
json_array_start(response, "state_changes");
|
||||
for (size_t i = 0; i < tal_count(state_changes); i++) {
|
||||
json_object_start(response, NULL);
|
||||
|
@ -1043,8 +1043,8 @@ char *wallet_offer_find(const tal_t *ctx UNNEEDED,
|
||||
|
||||
{ fprintf(stderr, "wallet_offer_find called!\n"); abort(); }
|
||||
/* Generated stub for wallet_state_change_get */
|
||||
struct state_change_entry *wallet_state_change_get(struct wallet *w UNNEEDED,
|
||||
const tal_t *ctx UNNEEDED,
|
||||
struct state_change_entry *wallet_state_change_get(const tal_t *ctx UNNEEDED,
|
||||
struct wallet *w UNNEEDED,
|
||||
u64 channel_id UNNEEDED)
|
||||
{ fprintf(stderr, "wallet_state_change_get called!\n"); abort(); }
|
||||
/* Generated stub for wallet_total_forward_fees */
|
||||
|
@ -2506,8 +2506,8 @@ void wallet_state_change_add(struct wallet *w,
|
||||
db_exec_prepared_v2(take(stmt));
|
||||
}
|
||||
|
||||
struct state_change_entry *wallet_state_change_get(struct wallet *w,
|
||||
const tal_t *ctx,
|
||||
struct state_change_entry *wallet_state_change_get(const tal_t *ctx,
|
||||
struct wallet *w,
|
||||
u64 channel_id)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
@ -4298,7 +4298,7 @@ void wallet_blocks_rollback(struct wallet *w, u32 height)
|
||||
db_exec_prepared_v2(take(stmt));
|
||||
}
|
||||
|
||||
bool wallet_outpoint_spend(struct wallet *w, const tal_t *ctx, const u32 blockheight,
|
||||
bool wallet_outpoint_spend(const tal_t *ctx, struct wallet *w, const u32 blockheight,
|
||||
const struct bitcoin_outpoint *outpoint)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
@ -4418,7 +4418,7 @@ bool wallet_have_block(struct wallet *w, u32 blockheight)
|
||||
return result;
|
||||
}
|
||||
|
||||
struct outpoint *wallet_outpoint_for_scid(struct wallet *w, tal_t *ctx,
|
||||
struct outpoint *wallet_outpoint_for_scid(const tal_t *ctx, struct wallet *w,
|
||||
const struct short_channel_id *scid)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
@ -4713,8 +4713,7 @@ void wallet_channeltxs_add(struct wallet *w, struct channel *chan,
|
||||
db_exec_prepared_v2(take(stmt));
|
||||
}
|
||||
|
||||
u32 *wallet_onchaind_channels(struct wallet *w,
|
||||
const tal_t *ctx)
|
||||
u32 *wallet_onchaind_channels(const tal_t *ctx, struct wallet *w)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
size_t count = 0;
|
||||
@ -4735,7 +4734,7 @@ u32 *wallet_onchaind_channels(struct wallet *w,
|
||||
return channel_ids;
|
||||
}
|
||||
|
||||
struct channeltx *wallet_channeltxs_get(struct wallet *w, const tal_t *ctx,
|
||||
struct channeltx *wallet_channeltxs_get(const tal_t *ctx, struct wallet *w,
|
||||
u32 channel_id)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
@ -4976,8 +4975,8 @@ struct amount_msat wallet_total_forward_fees(struct wallet *w)
|
||||
return total;
|
||||
}
|
||||
|
||||
const struct forwarding *wallet_forwarded_payments_get(struct wallet *w,
|
||||
const tal_t *ctx,
|
||||
const struct forwarding *wallet_forwarded_payments_get(const tal_t *ctx,
|
||||
struct wallet *w,
|
||||
enum forward_status status,
|
||||
const struct short_channel_id *chan_in,
|
||||
const struct short_channel_id *chan_out,
|
||||
@ -5280,7 +5279,7 @@ bool wallet_forward_delete(struct wallet *w,
|
||||
return changed;
|
||||
}
|
||||
|
||||
struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t *ctx)
|
||||
struct wallet_transaction *wallet_transactions_get(const tal_t *ctx, struct wallet *w)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
struct wallet_transaction *txs = tal_arr(ctx, struct wallet_transaction, 0);
|
||||
|
@ -663,8 +663,8 @@ void wallet_state_change_add(struct wallet *w,
|
||||
/**
|
||||
* Gets all state change history entries for a channel from the database
|
||||
*/
|
||||
struct state_change_entry *wallet_state_change_get(struct wallet *w,
|
||||
const tal_t *ctx,
|
||||
struct state_change_entry *wallet_state_change_get(const tal_t *ctx,
|
||||
struct wallet *w,
|
||||
u64 channel_id);
|
||||
|
||||
/**
|
||||
@ -1137,11 +1137,11 @@ bool wallet_have_block(struct wallet *w, u32 blockheight);
|
||||
*
|
||||
* @return true if found in our wallet's output set, false otherwise
|
||||
*/
|
||||
bool wallet_outpoint_spend(struct wallet *w, const tal_t *ctx,
|
||||
bool wallet_outpoint_spend(const tal_t *ctx, struct wallet *w,
|
||||
const u32 blockheight,
|
||||
const struct bitcoin_outpoint *outpoint);
|
||||
|
||||
struct outpoint *wallet_outpoint_for_scid(struct wallet *w, tal_t *ctx,
|
||||
struct outpoint *wallet_outpoint_for_scid(const tal_t *ctx, struct wallet *w,
|
||||
const struct short_channel_id *scid);
|
||||
|
||||
void wallet_utxoset_add(struct wallet *w,
|
||||
@ -1220,13 +1220,12 @@ void wallet_channeltxs_add(struct wallet *w, struct channel *chan,
|
||||
/**
|
||||
* List channels for which we had an onchaind running
|
||||
*/
|
||||
u32 *wallet_onchaind_channels(struct wallet *w,
|
||||
const tal_t *ctx);
|
||||
u32 *wallet_onchaind_channels(const tal_t *ctx, struct wallet *w);
|
||||
|
||||
/**
|
||||
* Get transactions that we'd like to replay for a channel.
|
||||
*/
|
||||
struct channeltx *wallet_channeltxs_get(struct wallet *w, const tal_t *ctx,
|
||||
struct channeltx *wallet_channeltxs_get(const tal_t *ctx, struct wallet *w,
|
||||
u32 channel_id);
|
||||
|
||||
/**
|
||||
@ -1247,8 +1246,8 @@ struct amount_msat wallet_total_forward_fees(struct wallet *w);
|
||||
/**
|
||||
* Retrieve a list of all forwarded_payments
|
||||
*/
|
||||
const struct forwarding *wallet_forwarded_payments_get(struct wallet *w,
|
||||
const tal_t *ctx,
|
||||
const struct forwarding *wallet_forwarded_payments_get(const tal_t *ctx,
|
||||
struct wallet *w,
|
||||
enum forward_status state,
|
||||
const struct short_channel_id *chan_in,
|
||||
const struct short_channel_id *chan_out,
|
||||
@ -1295,7 +1294,7 @@ void wallet_remote_ann_sigs_clear(struct wallet *w, const struct channel *chan);
|
||||
* @param wallet: Wallet to load from.
|
||||
* @return A tal_arr of wallet annotated transactions
|
||||
*/
|
||||
struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t *ctx);
|
||||
struct wallet_transaction *wallet_transactions_get(const tal_t *ctx, struct wallet *w);
|
||||
|
||||
/**
|
||||
* Add a filteredblock to the blocks and utxoset tables.
|
||||
|
@ -560,7 +560,7 @@ static struct command_result *json_listtransactions(struct command *cmd,
|
||||
if (!param(cmd, buffer, params, NULL))
|
||||
return command_param_failed();
|
||||
|
||||
txs = wallet_transactions_get(cmd->ld->wallet, cmd);
|
||||
txs = wallet_transactions_get(cmd, cmd->ld->wallet);
|
||||
|
||||
response = json_stream_success(cmd);
|
||||
json_array_start(response, "transactions");
|
||||
|
Loading…
Reference in New Issue
Block a user