Skip to content

Commit

Permalink
pettycoin-gateway: scan all transactions every time.
Browse files Browse the repository at this point in the history
This is a terrible solution which doesn't scale, but Works For Now.

Closes: #30

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Sep 4, 2014
1 parent d9a5640 commit 2af29f4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pettycoin-gateway.c
Expand Up @@ -480,7 +480,6 @@ int main(int argc, char *argv[])
bool setup = false;
struct thash thash;
int fd;
unsigned int known_txs = 0;

err_set_progname(argv[0]);

Expand Down Expand Up @@ -520,11 +519,11 @@ int main(int argc, char *argv[])
const jsmntok_t *t, *end;
const char *buffer;
const tal_t *this_ctx = tal(ctx, char);
char *fromstr = tal_fmt(this_ctx, "%u", known_txs);

/* FIXME: We should just get the latest, not all. */
toks = json_bitcoind(this_ctx, &buffer,
"listtransactions", "gateway",
"999999", fromstr);
"999999", NULL);

if (!toks)
err(1, "Asking bitcoind for transactions");
Expand Down Expand Up @@ -558,14 +557,16 @@ int main(int argc, char *argv[])
errx(1, "Unexpected type in"
" listtransactions array");

/* Ignore transactions we sent. */
val = json_get_member(buffer, t, "category");
if (!json_tok_streq(buffer, val, "receive"))
continue;

/* Not enough confirmations? Stop here. */
val = json_get_member(buffer, t, "confirmations");
if (num_of(buffer, val) < REQUIRED_CONFIRMATIONS)
break;

/* Next time, don't need this tx. */
known_txs++;

val = json_get_member(buffer, t, "txid");
if (!val)
errx(1, "No txid in '%s'", buffer);
Expand Down

0 comments on commit 2af29f4

Please sign in to comment.