mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
common: use tabs everywhere.
Didn't generally fixup inside comments and the bech32 code: reformatting that is just anti-social. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
5d2fdfe66b
commit
f376a9c24c
@ -8,6 +8,6 @@
|
|||||||
/* Given a scriptPubkey, return an encoded address */
|
/* Given a scriptPubkey, return an encoded address */
|
||||||
char *encode_scriptpubkey_to_addr(const tal_t *ctx,
|
char *encode_scriptpubkey_to_addr(const tal_t *ctx,
|
||||||
const struct chainparams *chainparams,
|
const struct chainparams *chainparams,
|
||||||
const u8 *scriptPubkey);
|
const u8 *scriptPubkey);
|
||||||
|
|
||||||
#endif /* LIGHTNING_COMMON_ADDR_H */
|
#endif /* LIGHTNING_COMMON_ADDR_H */
|
||||||
|
1128
common/bolt11.c
1128
common/bolt11.c
File diff suppressed because it is too large
Load Diff
@ -149,7 +149,7 @@ void daemon_setup(const char *argv0,
|
|||||||
* not start if it cannot do its job correctly. */
|
* not start if it cannot do its job correctly. */
|
||||||
if (sodium_init() == -1)
|
if (sodium_init() == -1)
|
||||||
errx(1, "Could not initialize libsodium. Maybe not enough entropy"
|
errx(1, "Could not initialize libsodium. Maybe not enough entropy"
|
||||||
" available ?");
|
" available ?");
|
||||||
|
|
||||||
/* We handle write returning errors! */
|
/* We handle write returning errors! */
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
@ -4,44 +4,44 @@
|
|||||||
|
|
||||||
void hash_u5_init(struct hash_u5 *hu5, const char *hrp)
|
void hash_u5_init(struct hash_u5 *hu5, const char *hrp)
|
||||||
{
|
{
|
||||||
hu5->buf = 0;
|
hu5->buf = 0;
|
||||||
hu5->num_bits = 0;
|
hu5->num_bits = 0;
|
||||||
sha256_init(&hu5->hash);
|
sha256_init(&hu5->hash);
|
||||||
sha256_update(&hu5->hash, hrp, strlen(hrp));
|
sha256_update(&hu5->hash, hrp, strlen(hrp));
|
||||||
}
|
}
|
||||||
|
|
||||||
void hash_u5(struct hash_u5 *hu5, const u8 *u5, size_t len)
|
void hash_u5(struct hash_u5 *hu5, const u8 *u5, size_t len)
|
||||||
{
|
{
|
||||||
size_t bits = len * 5;
|
size_t bits = len * 5;
|
||||||
|
|
||||||
while (bits) {
|
while (bits) {
|
||||||
size_t n = 5;
|
size_t n = 5;
|
||||||
|
|
||||||
if (bits < n)
|
if (bits < n)
|
||||||
n = bits;
|
n = bits;
|
||||||
|
|
||||||
hu5->buf <<= n;
|
hu5->buf <<= n;
|
||||||
hu5->buf |= (*u5 >> (5-n));
|
hu5->buf |= (*u5 >> (5-n));
|
||||||
bits -= n;
|
bits -= n;
|
||||||
hu5->num_bits += n;
|
hu5->num_bits += n;
|
||||||
|
|
||||||
if (n == 5)
|
if (n == 5)
|
||||||
u5++;
|
u5++;
|
||||||
|
|
||||||
if (hu5->num_bits >= 32) {
|
if (hu5->num_bits >= 32) {
|
||||||
be32 be32 = cpu_to_be32(hu5->buf >> (hu5->num_bits-32));
|
be32 be32 = cpu_to_be32(hu5->buf >> (hu5->num_bits-32));
|
||||||
sha256_update(&hu5->hash, &be32, sizeof(be32));
|
sha256_update(&hu5->hash, &be32, sizeof(be32));
|
||||||
hu5->num_bits -= 32;
|
hu5->num_bits -= 32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hash_u5_done(struct hash_u5 *hu5, struct sha256 *res)
|
void hash_u5_done(struct hash_u5 *hu5, struct sha256 *res)
|
||||||
{
|
{
|
||||||
if (hu5->num_bits) {
|
if (hu5->num_bits) {
|
||||||
be32 be32 = cpu_to_be32(hu5->buf << (32 - hu5->num_bits));
|
be32 be32 = cpu_to_be32(hu5->buf << (32 - hu5->num_bits));
|
||||||
|
|
||||||
sha256_update(&hu5->hash, &be32, (hu5->num_bits + 7) / 8);
|
sha256_update(&hu5->hash, &be32, (hu5->num_bits + 7) / 8);
|
||||||
}
|
}
|
||||||
sha256_done(&hu5->hash, res);
|
sha256_done(&hu5->hash, res);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
typedef unsigned char u5;
|
typedef unsigned char u5;
|
||||||
|
|
||||||
struct hash_u5 {
|
struct hash_u5 {
|
||||||
u64 buf;
|
u64 buf;
|
||||||
unsigned int num_bits;
|
unsigned int num_bits;
|
||||||
struct sha256_ctx hash;
|
struct sha256_ctx hash;
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ struct io_plan *io_lock_acquire_out_(struct io_conn *conn, struct io_lock *lock,
|
|||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
#define io_lock_acquire_in(conn, lock, next, arg) \
|
#define io_lock_acquire_in(conn, lock, next, arg) \
|
||||||
io_lock_acquire_in_((conn), (lock), \
|
io_lock_acquire_in_((conn), (lock), \
|
||||||
typesafe_cb_preargs(struct io_plan *, void *, \
|
typesafe_cb_preargs(struct io_plan *, void *, \
|
||||||
(next), (arg), \
|
(next), (arg), \
|
||||||
struct io_conn *), \
|
struct io_conn *), \
|
||||||
|
@ -123,7 +123,7 @@ bool json_to_number(const char *buffer, const jsmntok_t *tok,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool json_to_u16(const char *buffer, const jsmntok_t *tok,
|
bool json_to_u16(const char *buffer, const jsmntok_t *tok,
|
||||||
short unsigned int *num)
|
short unsigned int *num)
|
||||||
{
|
{
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ void json_tok_print(const char *buffer, const jsmntok_t *tok)
|
|||||||
printf("size: %d, count: %td\n", tok->size, last - first);
|
printf("size: %d, count: %td\n", tok->size, last - first);
|
||||||
while (first != last) {
|
while (first != last) {
|
||||||
printf("%td. %.*s, %s\n", first - tok,
|
printf("%td. %.*s, %s\n", first - tok,
|
||||||
first->end - first->start, buffer + first->start,
|
first->end - first->start, buffer + first->start,
|
||||||
jsmntype_to_string(first->type));
|
jsmntype_to_string(first->type));
|
||||||
first++;
|
first++;
|
||||||
}
|
}
|
||||||
@ -405,32 +405,32 @@ const jsmntok_t *json_delve(const char *buffer,
|
|||||||
const char *guide)
|
const char *guide)
|
||||||
{
|
{
|
||||||
while (*guide) {
|
while (*guide) {
|
||||||
const char *key;
|
const char *key;
|
||||||
size_t len = strcspn(guide+1, ".[]");
|
size_t len = strcspn(guide+1, ".[]");
|
||||||
|
|
||||||
key = tal_strndup(tmpctx, guide+1, len);
|
key = tal_strndup(tmpctx, guide+1, len);
|
||||||
switch (guide[0]) {
|
switch (guide[0]) {
|
||||||
case '.':
|
case '.':
|
||||||
if (tok->type != JSMN_OBJECT)
|
if (tok->type != JSMN_OBJECT)
|
||||||
return NULL;
|
return NULL;
|
||||||
tok = json_get_member(buffer, tok, key);
|
tok = json_get_member(buffer, tok, key);
|
||||||
if (!tok)
|
if (!tok)
|
||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
if (tok->type != JSMN_ARRAY)
|
if (tok->type != JSMN_ARRAY)
|
||||||
return NULL;
|
return NULL;
|
||||||
tok = json_get_arr(tok, atol(key));
|
tok = json_get_arr(tok, atol(key));
|
||||||
if (!tok)
|
if (!tok)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* Must be terminated */
|
/* Must be terminated */
|
||||||
assert(guide[1+strlen(key)] == ']');
|
assert(guide[1+strlen(key)] == ']');
|
||||||
len++;
|
len++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
guide += len + 1;
|
guide += len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tok;
|
return tok;
|
||||||
|
@ -63,7 +63,7 @@ bool json_to_s64(const char *buffer, const jsmntok_t *tok, s64 *num);
|
|||||||
|
|
||||||
/* Extract number from this (may be a string, or a number literal) */
|
/* Extract number from this (may be a string, or a number literal) */
|
||||||
bool json_to_u32(const char *buffer, const jsmntok_t *tok,
|
bool json_to_u32(const char *buffer, const jsmntok_t *tok,
|
||||||
uint32_t *num);
|
uint32_t *num);
|
||||||
|
|
||||||
/* Extract number from this (may be a string, or a number literal) */
|
/* Extract number from this (may be a string, or a number literal) */
|
||||||
bool json_to_u16(const char *buffer, const jsmntok_t *tok,
|
bool json_to_u16(const char *buffer, const jsmntok_t *tok,
|
||||||
|
@ -202,7 +202,7 @@ struct command_result *param_sat_or_all(struct command *cmd, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct command_result *param_node_id(struct command *cmd, const char *name,
|
struct command_result *param_node_id(struct command *cmd, const char *name,
|
||||||
const char *buffer, const jsmntok_t *tok,
|
const char *buffer, const jsmntok_t *tok,
|
||||||
struct node_id **id)
|
struct node_id **id)
|
||||||
{
|
{
|
||||||
*id = tal(cmd, struct node_id);
|
*id = tal(cmd, struct node_id);
|
||||||
|
@ -8,7 +8,7 @@ bool derive_keyset(const struct pubkey *per_commitment_point,
|
|||||||
bool option_static_remotekey,
|
bool option_static_remotekey,
|
||||||
struct keyset *keyset)
|
struct keyset *keyset)
|
||||||
{
|
{
|
||||||
/* BOLT #3:
|
/* BOLT #3:
|
||||||
*
|
*
|
||||||
* ### `localpubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation
|
* ### `localpubkey`, `local_htlcpubkey`, `remote_htlcpubkey`, `local_delayedpubkey`, and `remote_delayedpubkey` Derivation
|
||||||
*
|
*
|
||||||
|
@ -73,7 +73,7 @@ const char *param_subcommand(struct command *cmd, const char *buffer,
|
|||||||
/*
|
/*
|
||||||
* Add a required parameter.
|
* Add a required parameter.
|
||||||
*/
|
*/
|
||||||
#define p_req(name, cbx, arg) \
|
#define p_req(name, cbx, arg) \
|
||||||
name"", \
|
name"", \
|
||||||
true, \
|
true, \
|
||||||
(param_cbx)(cbx), \
|
(param_cbx)(cbx), \
|
||||||
|
@ -35,7 +35,7 @@ static size_t find_best_in(struct wally_tx_input *inputs, size_t num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void swap_wally_inputs(struct wally_tx_input *inputs,
|
static void swap_wally_inputs(struct wally_tx_input *inputs,
|
||||||
const void **map,
|
const void **map,
|
||||||
size_t i1, size_t i2)
|
size_t i1, size_t i2)
|
||||||
{
|
{
|
||||||
struct wally_tx_input tmpinput;
|
struct wally_tx_input tmpinput;
|
||||||
|
@ -138,6 +138,6 @@ void tal_arr_remove_(void *p, size_t elemsize, size_t n)
|
|||||||
assert(len % elemsize == 0);
|
assert(len % elemsize == 0);
|
||||||
assert((n + 1) * elemsize <= len);
|
assert((n + 1) * elemsize <= len);
|
||||||
memmove(objp + elemsize * n, objp + elemsize * (n+1),
|
memmove(objp + elemsize * n, objp + elemsize * (n+1),
|
||||||
len - (elemsize * (n+1)));
|
len - (elemsize * (n+1)));
|
||||||
tal_resize((char **)p, len - elemsize);
|
tal_resize((char **)p, len - elemsize);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ struct command_result *param_wtx(struct command *cmd,
|
|||||||
buffer + tok->start);
|
buffer + tok->start);
|
||||||
|
|
||||||
if (amount_sat_greater(wtx->amount, max))
|
if (amount_sat_greater(wtx->amount, max))
|
||||||
return command_fail(wtx->cmd, FUND_MAX_EXCEEDED,
|
return command_fail(wtx->cmd, FUND_MAX_EXCEEDED,
|
||||||
"Amount exceeded %s",
|
"Amount exceeded %s",
|
||||||
type_to_string(tmpctx, struct amount_sat,
|
type_to_string(tmpctx, struct amount_sat,
|
||||||
&max));
|
&max));
|
||||||
|
@ -311,7 +311,7 @@ static bool separate_address_and_port(const tal_t *ctx, const char *arg,
|
|||||||
|
|
||||||
struct wireaddr *
|
struct wireaddr *
|
||||||
wireaddr_from_hostname(const tal_t *ctx,
|
wireaddr_from_hostname(const tal_t *ctx,
|
||||||
const char *hostname,
|
const char *hostname,
|
||||||
const u16 port, bool *no_dns,
|
const u16 port, bool *no_dns,
|
||||||
struct sockaddr *broken_reply,
|
struct sockaddr *broken_reply,
|
||||||
const char **err_msg)
|
const char **err_msg)
|
||||||
|
@ -90,7 +90,7 @@ char *fmt_wireaddr_without_port(const tal_t *ctx, const struct wireaddr *a);
|
|||||||
* we wanted to do a DNS lookup. */
|
* we wanted to do a DNS lookup. */
|
||||||
struct wireaddr *
|
struct wireaddr *
|
||||||
wireaddr_from_hostname(const tal_t *ctx,
|
wireaddr_from_hostname(const tal_t *ctx,
|
||||||
const char *hostname,
|
const char *hostname,
|
||||||
const u16 port, bool *no_dns,
|
const u16 port, bool *no_dns,
|
||||||
struct sockaddr *broken_reply,
|
struct sockaddr *broken_reply,
|
||||||
const char **err_msg);
|
const char **err_msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user