Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2af29f4

Browse files
committedSep 4, 2014
pettycoin-gateway: scan all transactions every time.
This is a terrible solution which doesn't scale, but Works For Now. Closes: #30 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent d9a5640 commit 2af29f4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎pettycoin-gateway.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ int main(int argc, char *argv[])
480480
bool setup = false;
481481
struct thash thash;
482482
int fd;
483-
unsigned int known_txs = 0;
484483

485484
err_set_progname(argv[0]);
486485

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

523+
/* FIXME: We should just get the latest, not all. */
525524
toks = json_bitcoind(this_ctx, &buffer,
526525
"listtransactions", "gateway",
527-
"999999", fromstr);
526+
"999999", NULL);
528527

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

560+
/* Ignore transactions we sent. */
561+
val = json_get_member(buffer, t, "category");
562+
if (!json_tok_streq(buffer, val, "receive"))
563+
continue;
564+
561565
/* Not enough confirmations? Stop here. */
562566
val = json_get_member(buffer, t, "confirmations");
563567
if (num_of(buffer, val) < REQUIRED_CONFIRMATIONS)
564568
break;
565569

566-
/* Next time, don't need this tx. */
567-
known_txs++;
568-
569570
val = json_get_member(buffer, t, "txid");
570571
if (!val)
571572
errx(1, "No txid in '%s'", buffer);

0 commit comments

Comments
 (0)
Please sign in to comment.