diff --git a/common/utxo.h b/common/utxo.h index c31d40641..7f996ffb1 100644 --- a/common/utxo.h +++ b/common/utxo.h @@ -28,10 +28,10 @@ struct utxo { struct unilateral_close_info *close_info; /* NULL if we haven't seen it in a block, otherwise the block it's in */ - const int *blockheight; + const u32 *blockheight; /* NULL if not spent yet, otherwise, the block the spending transaction is in */ - const int *spendheight; + const u32 *spendheight; }; void towire_utxo(u8 **pptr, const struct utxo *utxo); diff --git a/lightningd/chaintopology.c b/lightningd/chaintopology.c index 114fb2a25..727e2b36f 100644 --- a/lightningd/chaintopology.c +++ b/lightningd/chaintopology.c @@ -77,7 +77,8 @@ static void filter_block_txs(struct chain_topology *topo, struct block *b) satoshi_owned = 0; if (txfilter_match(topo->bitcoind->ld->owned_txfilter, tx)) { wallet_extract_owned_outputs(topo->bitcoind->ld->wallet, - tx, b, &satoshi_owned); + tx, &b->height, + &satoshi_owned); } /* We did spends first, in case that tells us to watch tx. */ diff --git a/lightningd/chaintopology.h b/lightningd/chaintopology.h index a6fc84196..d1934bb3f 100644 --- a/lightningd/chaintopology.h +++ b/lightningd/chaintopology.h @@ -35,7 +35,7 @@ struct outgoing_tx { }; struct block { - int height; + u32 height; /* Actual header. */ struct bitcoin_block_hdr hdr; diff --git a/wallet/wallet.c b/wallet/wallet.c index a06483517..460d03f1e 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -117,7 +117,7 @@ bool wallet_add_utxo(struct wallet *w, struct utxo *utxo, */ static bool wallet_stmt2output(sqlite3_stmt *stmt, struct utxo *utxo) { - int *blockheight, *spendheight; + u32 *blockheight, *spendheight; sqlite3_column_sha256_double(stmt, 0, &utxo->txid.shad); utxo->outnum = sqlite3_column_int(stmt, 1); utxo->amount = sqlite3_column_int64(stmt, 2); @@ -137,13 +137,13 @@ static bool wallet_stmt2output(sqlite3_stmt *stmt, struct utxo *utxo) utxo->spendheight = NULL; if (sqlite3_column_type(stmt, 9) != SQLITE_NULL) { - blockheight = tal(utxo, int); + blockheight = tal(utxo, u32); *blockheight = sqlite3_column_int(stmt, 9); utxo->blockheight = blockheight; } if (sqlite3_column_type(stmt, 10) != SQLITE_NULL) { - spendheight = tal(utxo, int); + spendheight = tal(utxo, u32); *spendheight = sqlite3_column_int(stmt, 10); utxo->spendheight = spendheight; } @@ -1071,7 +1071,7 @@ static void wallet_output_confirm(struct wallet *w, } int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, - const struct block *block, u64 *total_satoshi) + const u32 *blockheight, u64 *total_satoshi) { int num_utxos = 0; for (size_t output = 0; output < tal_count(tx->output); output++) { @@ -1092,7 +1092,7 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, utxo->outnum = output; utxo->close_info = NULL; - utxo->blockheight = block?&block->height:NULL; + utxo->blockheight = blockheight?blockheight:NULL; utxo->spendheight = NULL; log_debug(w->log, "Owning output %zu %"PRIu64" (%s) txid %s", @@ -1107,8 +1107,8 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, * blockheight. This can happen when we grab * the output from a transaction we created * ourselves. */ - if (block) - wallet_output_confirm(w, &utxo->txid, utxo->outnum, block->height); + if (blockheight) + wallet_output_confirm(w, &utxo->txid, utxo->outnum, *blockheight); tal_free(utxo); continue; } diff --git a/wallet/wallet.h b/wallet/wallet.h index bdab3d76b..bc162fc5f 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -315,7 +315,7 @@ u32 wallet_first_blocknum(struct wallet *w, u32 first_possible); * wallet_extract_owned_outputs - given a tx, extract all of our outputs */ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, - const struct block *block, u64 *total_satoshi); + const u32 *blockheight, u64 *total_satoshi); /** * wallet_htlc_save_in - store an htlc_in in the database