mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
wallet: Pass in timers object during construction.
In preparation for expiration.
This commit is contained in:
parent
8be1c1df32
commit
1e6747c28e
@ -281,7 +281,7 @@ int main(int argc, char *argv[])
|
||||
test_daemons(ld);
|
||||
|
||||
/* Initialize wallet, now that we are in the correct directory */
|
||||
ld->wallet = wallet_new(ld, ld->log);
|
||||
ld->wallet = wallet_new(ld, ld->log, &ld->timers);
|
||||
ld->owned_txfilter = txfilter_new(ld);
|
||||
|
||||
/* Set up HSM. */
|
||||
|
@ -112,7 +112,8 @@ bool wallet_htlcs_reconnect(struct wallet *wallet UNNEEDED,
|
||||
bool wallet_invoice_load(struct wallet *wallet UNNEEDED)
|
||||
{ fprintf(stderr, "wallet_invoice_load called!\n"); abort(); }
|
||||
/* Generated stub for wallet_new */
|
||||
struct wallet *wallet_new(const tal_t *ctx UNNEEDED, struct log *log UNNEEDED)
|
||||
struct wallet *wallet_new(const tal_t *ctx UNNEEDED,
|
||||
struct log *log UNNEEDED, struct timers *timers UNNEEDED)
|
||||
{ fprintf(stderr, "wallet_new called!\n"); abort(); }
|
||||
/* AUTOGENERATED MOCKS END */
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <ccan/structeq/structeq.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <ccan/time/time.h>
|
||||
#include <ccan/timer/timer.h>
|
||||
#include <lightningd/invoice.h>
|
||||
#include <lightningd/log.h>
|
||||
#include <sodium/randombytes.h>
|
||||
@ -24,6 +25,8 @@ struct invoices {
|
||||
struct db *db;
|
||||
/* The log to report to. */
|
||||
struct log *log;
|
||||
/* The timers object to use for expirations. */
|
||||
struct timers *timers;
|
||||
/* The invoice list. */
|
||||
struct list_head invlist;
|
||||
/* Waiters waiting for any new invoice to be paid. */
|
||||
@ -71,12 +74,14 @@ static bool wallet_stmt2invoice(sqlite3_stmt *stmt, struct invoice *inv)
|
||||
|
||||
struct invoices *invoices_new(const tal_t *ctx,
|
||||
struct db *db,
|
||||
struct log *log)
|
||||
struct log *log,
|
||||
struct timers *timers)
|
||||
{
|
||||
struct invoices *invs = tal(ctx, struct invoices);
|
||||
|
||||
invs->db = db;
|
||||
invs->log = log;
|
||||
invs->timers = timers;
|
||||
|
||||
list_head_init(&invs->invlist);
|
||||
list_head_init(&invs->waitany_waiters);
|
||||
|
@ -10,6 +10,7 @@ struct invoice;
|
||||
struct invoices;
|
||||
struct log;
|
||||
struct sha256;
|
||||
struct timers;
|
||||
|
||||
/**
|
||||
* invoices_new - Constructor for a new invoice handler
|
||||
@ -17,10 +18,12 @@ struct sha256;
|
||||
* @ctx - the owner of the invoice handler.
|
||||
* @db - the database connection to use for saving invoice.
|
||||
* @log - the log to report to.
|
||||
* @timers - the timers object to use for expirations.
|
||||
*/
|
||||
struct invoices *invoices_new(const tal_t *ctx,
|
||||
struct db *db,
|
||||
struct log *log);
|
||||
struct log *log,
|
||||
struct timers *timers);
|
||||
|
||||
/**
|
||||
* invoices_load - Second-stage constructor for invoice handler.
|
||||
|
@ -16,13 +16,14 @@
|
||||
#define DIRECTION_INCOMING 0
|
||||
#define DIRECTION_OUTGOING 1
|
||||
|
||||
struct wallet *wallet_new(const tal_t *ctx, struct log *log)
|
||||
struct wallet *wallet_new(const tal_t *ctx,
|
||||
struct log *log, struct timers *timers)
|
||||
{
|
||||
struct wallet *wallet = tal(ctx, struct wallet);
|
||||
wallet->db = db_setup(wallet, log);
|
||||
wallet->log = log;
|
||||
wallet->bip32_base = NULL;
|
||||
wallet->invoices = invoices_new(wallet, wallet->db, log);
|
||||
wallet->invoices = invoices_new(wallet, wallet->db, log, timers);
|
||||
list_head_init(&wallet->unstored_payments);
|
||||
return wallet;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
struct invoices;
|
||||
struct lightningd;
|
||||
struct pubkey;
|
||||
struct timers;
|
||||
|
||||
struct wallet {
|
||||
struct db *db;
|
||||
@ -105,7 +106,8 @@ struct wallet_payment {
|
||||
* This is guaranteed to either return a valid wallet, or abort with
|
||||
* `fatal` if it cannot be initialized.
|
||||
*/
|
||||
struct wallet *wallet_new(const tal_t *ctx, struct log *log);
|
||||
struct wallet *wallet_new(const tal_t *ctx,
|
||||
struct log *log, struct timers *timers);
|
||||
|
||||
/**
|
||||
* wallet_add_utxo - Register a UTXO which we (partially) own
|
||||
|
Loading…
Reference in New Issue
Block a user