From fc54bfc48835de5df357496ee2f64c609563bda6 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Wed, 1 Apr 2020 21:55:44 -0500 Subject: [PATCH] coin moves: record wallet deposits --- wallet/test/run-wallet.c | 15 +++++++++++++++ wallet/wallet.c | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index b2d9aace8..abeb8db2a 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -384,6 +384,18 @@ bool json_tok_streq(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED, const char *why UNNEEDED) { fprintf(stderr, "kill_uncommitted_channel called!\n"); abort(); } +/* Generated stub for new_chain_coin_mvt_sat */ +struct chain_coin_mvt *new_chain_coin_mvt_sat(const tal_t *ctx UNNEEDED, + const char *account_name UNNEEDED, + const struct bitcoin_txid *tx_txid UNNEEDED, + const struct bitcoin_txid *output_txid UNNEEDED, + u32 vout UNNEEDED, + struct sha256 *payment_hash UNNEEDED, + enum mvt_tag tag UNNEEDED, + struct amount_sat amt_sat UNNEEDED, + bool is_credit UNNEEDED, + enum mvt_unit_type unit UNNEEDED) +{ fprintf(stderr, "new_chain_coin_mvt_sat called!\n"); abort(); } /* Generated stub for new_channel_coin_mvt */ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx UNNEEDED, struct bitcoin_txid *funding_txid UNNEEDED, @@ -395,6 +407,9 @@ struct channel_coin_mvt *new_channel_coin_mvt(const tal_t *ctx UNNEEDED, bool is_credit UNNEEDED, enum mvt_unit_type unit UNNEEDED) { fprintf(stderr, "new_channel_coin_mvt called!\n"); abort(); } +/* Generated stub for notify_chain_mvt */ +void notify_chain_mvt(struct lightningd *ld UNNEEDED, const struct chain_coin_mvt *mvt UNNEEDED) +{ fprintf(stderr, "notify_chain_mvt called!\n"); abort(); } /* Generated stub for notify_channel_mvt */ void notify_channel_mvt(struct lightningd *ld UNNEEDED, const struct channel_coin_mvt *mvt UNNEEDED) { fprintf(stderr, "notify_channel_mvt called!\n"); abort(); } diff --git a/wallet/wallet.c b/wallet/wallet.c index 557174c4a..7b80d2be6 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1620,6 +1621,7 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, bool is_p2sh; const u8 *script; struct amount_asset asset = bitcoin_tx_output_get_amount(tx, output); + struct chain_coin_mvt *mvt; if (!amount_asset_is_main(&asset)) continue; @@ -1664,6 +1666,13 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, continue; } + /* add this to our wallet amount */ + mvt = new_chain_coin_mvt_sat(utxo, "wallet", &utxo->txid, + &utxo->txid, utxo->outnum, + NULL, DEPOSIT, utxo->amount, + true, BTC); + notify_chain_mvt(w->ld, mvt); + /* This is an unconfirmed change output, we should track it */ if (!is_p2sh && !blockheight) txfilter_add_scriptpubkey(w->ld->owned_txfilter, script);