opt_bits: parsing routines for 'bits' == 100 satoshi.

Also fix open-channel usage message.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2015-06-07 13:51:09 +09:30
parent 126192a842
commit fc8552318a
4 changed files with 32 additions and 20 deletions

View File

@@ -19,28 +19,11 @@
#include "shadouble.h"
#include <openssl/ec.h>
#include <unistd.h>
#include "opt_bits.h"
/* Bitcoin nodes are allowed to be 2 hours in the future. */
#define LOCKTIME_MIN (2 * 60 * 60)
static char *opt_set_bits(const char *arg, u64 *satoshi)
{
unsigned long long ll;
char *ret = opt_set_ulonglongval_si(arg, &ll);
if (ret)
return ret;
*satoshi = ll * 100;
if (*satoshi / 100 != ll)
return "Invalid number of bits";
return NULL;
}
static void opt_show_bits(char buf[OPT_SHOW_LEN], const u64 *bits)
{
unsigned long long ll = *bits / 100;
opt_show_ulonglongval_si(buf, &ll);
}
static BitcoinInput *parse_anchor_input(const tal_t *ctx, const char *spec)
{
BitcoinInput *in = tal(ctx, BitcoinInput);
@@ -110,7 +93,7 @@ int main(int argc, char *argv[])
locktime_seconds = LOCKTIME_MIN + 24 * 60 * 60;
opt_register_noarg("--help|-h", opt_usage_and_exit,
"<seed> <amount> <changepubkey> <commitprivkey> <outpubkey> <txid>/<outnum>/<satoshis>/<script-in-hex>...\n"
"<seed> <amount> <changepubkey> <commitprivkey> <outprivkey> <txid>/<outnum>/<satoshis>/<script-in-hex>...\n"
"A test program to output openchannel on stdout.",
"Print this message.");
opt_register_arg("--min-anchor-confirms",