mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
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:
parent
126192a842
commit
fc8552318a
4 changed files with 32 additions and 20 deletions
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ PROTOCC:=protoc-c
|
|||
|
||||
PROGRAMS := open-channel open-anchor-scriptsigs leak-anchor-sigs open-commit-sig check-commit-sig check-anchor-scriptsigs get-anchor-depth create-steal-tx
|
||||
|
||||
HELPER_OBJS := base58.o lightning.pb-c.o shadouble.o pkt.o bitcoin_script.o permute_tx.o signature.o bitcoin_tx.o bitcoin_address.o anchor.o commit_tx.o pubkey.o
|
||||
HELPER_OBJS := base58.o lightning.pb-c.o shadouble.o pkt.o bitcoin_script.o permute_tx.o signature.o bitcoin_tx.o bitcoin_address.o anchor.o commit_tx.o pubkey.o opt_bits.o
|
||||
|
||||
CCAN_OBJS := ccan-crypto-sha256.o ccan-crypto-shachain.o ccan-err.o ccan-tal.o ccan-tal-str.o ccan-take.o ccan-list.o ccan-str.o ccan-opt-helpers.o ccan-opt.o ccan-opt-parse.o ccan-opt-usage.o ccan-read_write_all.o ccan-str-hex.o ccan-tal-grab_file.o ccan-noerr.o
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
20
opt_bits.c
Normal file
20
opt_bits.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "opt_bits.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void opt_show_bits(char buf[OPT_SHOW_LEN], const u64 *bits)
|
||||
{
|
||||
unsigned long long ll = *bits / 100;
|
||||
opt_show_ulonglongval_si(buf, &ll);
|
||||
}
|
||||
|
9
opt_bits.h
Normal file
9
opt_bits.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef LIGHTNING_OPT_BITS_H
|
||||
#define LIGHTNING_OPT_BITS_H
|
||||
#include <ccan/opt/opt.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
|
||||
char *opt_set_bits(const char *arg, u64 *satoshi);
|
||||
void opt_show_bits(char buf[OPT_SHOW_LEN], const u64 *bits);
|
||||
|
||||
#endif /* LIGHTNING_OPT_BITS_H */
|
Loading…
Add table
Reference in a new issue