coin moves: record wallet deposits

This commit is contained in:
lisa neigut 2020-04-01 21:55:44 -05:00 committed by Rusty Russell
parent e623143c9f
commit fc54bfc488
2 changed files with 24 additions and 0 deletions

View file

@ -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(); }

View file

@ -11,6 +11,7 @@
#include <common/onionreply.h>
#include <common/wireaddr.h>
#include <inttypes.h>
#include <lightningd/coin_mvts.h>
#include <lightningd/lightningd.h>
#include <lightningd/notification.h>
#include <lightningd/peer_control.h>
@ -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);