Skip to content

Commit

Permalink
daemon: make logic in bitcoind interface more explicit.
Browse files Browse the repository at this point in the history
In particular, we expect not to have a block hash if (and only if!) confirmations == 0.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Apr 1, 2016
1 parent e8a83c3 commit cc7cb01
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions daemon/bitcoind.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,14 @@ static void process_transactions(struct bitcoin_cli *bcli)

/* This can happen with zero conf. */
blkindxtok = json_get_member(bcli->output, t, "blockindex");
if (!blkindxtok)
if (!blkindxtok) {
if (conf != 0)
fatal("listtransactions: no blockindex");
is_coinbase = false;
else {
} else {
unsigned int blkidx;
if (conf == 0)
fatal("listtransactions: expect no blockindex");
if (!json_tok_number(bcli->output, blkindxtok, &blkidx))
fatal("listtransactions: bad blockindex '%.*s'",
(int)(blkindxtok->end - blkindxtok->start),
Expand All @@ -254,7 +258,8 @@ static void process_transactions(struct bitcoin_cli *bcli)
txid.sha.u.u8[2], txid.sha.u.u8[3],
conf, is_coinbase);

cb(bcli->dstate, &txid, conf, is_coinbase, &blkhash);
cb(bcli->dstate, &txid, conf, is_coinbase,
conf ? &blkhash : NULL);
}
}

Expand Down

0 comments on commit cc7cb01

Please sign in to comment.