Browse files

blksrc: add new option

  • Loading branch information...
1 parent 8f88338 commit 5470389455bbf2bb7086528cc6e3331e3a993c93 Jeff Garzik committed Jan 11, 2014
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/blkscan.c
View
13 src/blkscan.c
@@ -31,6 +31,9 @@ static struct argp_option options[] = {
{ "blocks", 'b', "FILE", 0,
"Load blockchain data from mkbootstrap-produced FILE. Default filename \"addresses.txt\"." },
+ { "no-decimal", 'N', NULL, 0,
+ "Print values as integers (satoshis), not decimal numbers" },
+
{ "quiet", 'q', NULL, 0,
"Silence informational messages" },
@@ -43,6 +46,7 @@ static const char doc[] =
static char *blocks_fn = "blocks.dat";
static char *address_fn = "addresses.txt";
static bool opt_quiet = false;
+static bool opt_decimal = true;
static struct bp_keyset bpks;
static GHashTable *tx_idx = NULL;
@@ -61,6 +65,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
case 'b':
blocks_fn = arg;
break;
+ case 'N':
+ opt_decimal = false;
+ break;
case 'q':
opt_quiet = true;
break;
@@ -216,7 +223,11 @@ static int block_fd = -1;
static void print_txout(bool show_from, unsigned int i, struct bp_txout *txout)
{
char valstr[VALSTR_SZ];
- btc_decimal(valstr, VALSTR_SZ, txout->nValue);
+ if (opt_decimal)
+ btc_decimal(valstr, VALSTR_SZ, txout->nValue);
+ else
+ snprintf(valstr, sizeof(valstr), "%lld",
+ (long long) txout->nValue);
printf("\t%s %u: %s",
show_from ? "\tFrom" : "Output",

0 comments on commit 5470389

Please sign in to comment.