Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: listtransactions crash #3231 #3256

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
wallet: fix accessing blockheight of unconfirmed transaction
  • Loading branch information
m-schmoock committed Nov 14, 2019
commit bf1fb7ea79fc5999a87a25092d709710321165c9
14 changes: 11 additions & 3 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3445,7 +3445,7 @@ struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t
" transaction_annotations a ON (a.txid = t.id) LEFT JOIN"
" channels c ON (a.channel = c.id) LEFT JOIN"
" channels c2 ON (t.channel_id = c2.id) "
"ORDER BY blockheight, txindex ASC"));
"ORDER BY t.blockheight, t.txindex ASC"));
db_query_prepared(stmt);

for (count = 0; db_step(stmt); count++) {
Expand All @@ -3463,8 +3463,16 @@ struct wallet_transaction *wallet_transactions_get(struct wallet *w, const tal_t
cur->tx = db_column_tx(txs, stmt, 1);
cur->rawtx = tal_dup_arr(txs, u8, db_column_blob(stmt, 1),
db_column_bytes(stmt, 1), 0);
cur->blockheight = db_column_int(stmt, 2);
cur->txindex = db_column_int(stmt, 3);
/* TX may be unconfirmed. */
if (!db_column_is_null(stmt, 2) || !db_column_is_null(stmt, 3)) {
/* assert incomplete information */
assert(!db_column_is_null(stmt, 2) && !db_column_is_null(stmt, 3));
cur->blockheight = db_column_int(stmt, 2);
cur->txindex = db_column_int(stmt, 3);
} else {
cur->blockheight = 0;
cur->txindex = 0;
}
if (!db_column_is_null(stmt, 4))
cur->annotation.type = db_column_u64(stmt, 4);
else
Expand Down