mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
cleanup: Make blockheights unsigned
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
aba0b0e01b
commit
ba7341ec87
@@ -28,10 +28,10 @@ struct utxo {
|
|||||||
struct unilateral_close_info *close_info;
|
struct unilateral_close_info *close_info;
|
||||||
|
|
||||||
/* NULL if we haven't seen it in a block, otherwise the block it's in */
|
/* 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 */
|
/* 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);
|
void towire_utxo(u8 **pptr, const struct utxo *utxo);
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ static void filter_block_txs(struct chain_topology *topo, struct block *b)
|
|||||||
satoshi_owned = 0;
|
satoshi_owned = 0;
|
||||||
if (txfilter_match(topo->bitcoind->ld->owned_txfilter, tx)) {
|
if (txfilter_match(topo->bitcoind->ld->owned_txfilter, tx)) {
|
||||||
wallet_extract_owned_outputs(topo->bitcoind->ld->wallet,
|
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. */
|
/* We did spends first, in case that tells us to watch tx. */
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ struct outgoing_tx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct block {
|
struct block {
|
||||||
int height;
|
u32 height;
|
||||||
|
|
||||||
/* Actual header. */
|
/* Actual header. */
|
||||||
struct bitcoin_block_hdr hdr;
|
struct bitcoin_block_hdr hdr;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ bool wallet_add_utxo(struct wallet *w, struct utxo *utxo,
|
|||||||
*/
|
*/
|
||||||
static bool wallet_stmt2output(sqlite3_stmt *stmt, 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);
|
sqlite3_column_sha256_double(stmt, 0, &utxo->txid.shad);
|
||||||
utxo->outnum = sqlite3_column_int(stmt, 1);
|
utxo->outnum = sqlite3_column_int(stmt, 1);
|
||||||
utxo->amount = sqlite3_column_int64(stmt, 2);
|
utxo->amount = sqlite3_column_int64(stmt, 2);
|
||||||
@@ -137,13 +137,13 @@ static bool wallet_stmt2output(sqlite3_stmt *stmt, struct utxo *utxo)
|
|||||||
utxo->spendheight = NULL;
|
utxo->spendheight = NULL;
|
||||||
|
|
||||||
if (sqlite3_column_type(stmt, 9) != SQLITE_NULL) {
|
if (sqlite3_column_type(stmt, 9) != SQLITE_NULL) {
|
||||||
blockheight = tal(utxo, int);
|
blockheight = tal(utxo, u32);
|
||||||
*blockheight = sqlite3_column_int(stmt, 9);
|
*blockheight = sqlite3_column_int(stmt, 9);
|
||||||
utxo->blockheight = blockheight;
|
utxo->blockheight = blockheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqlite3_column_type(stmt, 10) != SQLITE_NULL) {
|
if (sqlite3_column_type(stmt, 10) != SQLITE_NULL) {
|
||||||
spendheight = tal(utxo, int);
|
spendheight = tal(utxo, u32);
|
||||||
*spendheight = sqlite3_column_int(stmt, 10);
|
*spendheight = sqlite3_column_int(stmt, 10);
|
||||||
utxo->spendheight = spendheight;
|
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,
|
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;
|
int num_utxos = 0;
|
||||||
for (size_t output = 0; output < tal_count(tx->output); output++) {
|
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->outnum = output;
|
||||||
utxo->close_info = NULL;
|
utxo->close_info = NULL;
|
||||||
|
|
||||||
utxo->blockheight = block?&block->height:NULL;
|
utxo->blockheight = blockheight?blockheight:NULL;
|
||||||
utxo->spendheight = NULL;
|
utxo->spendheight = NULL;
|
||||||
|
|
||||||
log_debug(w->log, "Owning output %zu %"PRIu64" (%s) txid %s",
|
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
|
* blockheight. This can happen when we grab
|
||||||
* the output from a transaction we created
|
* the output from a transaction we created
|
||||||
* ourselves. */
|
* ourselves. */
|
||||||
if (block)
|
if (blockheight)
|
||||||
wallet_output_confirm(w, &utxo->txid, utxo->outnum, block->height);
|
wallet_output_confirm(w, &utxo->txid, utxo->outnum, *blockheight);
|
||||||
tal_free(utxo);
|
tal_free(utxo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
* 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,
|
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
|
* wallet_htlc_save_in - store an htlc_in in the database
|
||||||
|
|||||||
Reference in New Issue
Block a user