Skip to content

Commit cc7cb01

Browse files
committed
daemon: make logic in bitcoind interface more explicit.
In particular, we expect not to have a block hash if (and only if!) confirmations == 0. Signed-off-by: Rusty Russell <[email protected]>
1 parent e8a83c3 commit cc7cb01

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

daemon/bitcoind.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,14 @@ static void process_transactions(struct bitcoin_cli *bcli)
225225

226226
/* This can happen with zero conf. */
227227
blkindxtok = json_get_member(bcli->output, t, "blockindex");
228-
if (!blkindxtok)
228+
if (!blkindxtok) {
229+
if (conf != 0)
230+
fatal("listtransactions: no blockindex");
229231
is_coinbase = false;
230-
else {
232+
} else {
231233
unsigned int blkidx;
234+
if (conf == 0)
235+
fatal("listtransactions: expect no blockindex");
232236
if (!json_tok_number(bcli->output, blkindxtok, &blkidx))
233237
fatal("listtransactions: bad blockindex '%.*s'",
234238
(int)(blkindxtok->end - blkindxtok->start),
@@ -254,7 +258,8 @@ static void process_transactions(struct bitcoin_cli *bcli)
254258
txid.sha.u.u8[2], txid.sha.u.u8[3],
255259
conf, is_coinbase);
256260

257-
cb(bcli->dstate, &txid, conf, is_coinbase, &blkhash);
261+
cb(bcli->dstate, &txid, conf, is_coinbase,
262+
conf ? &blkhash : NULL);
258263
}
259264
}
260265

0 commit comments

Comments
 (0)