|
@ -248,9 +248,8 @@ static char *decode_x(struct bolt11 *b11, |
|
|
/* BOLT #11:
|
|
|
/* BOLT #11:
|
|
|
* |
|
|
* |
|
|
* `c` (24): `data_length` variable. `min_final_cltv_expiry` to use for the |
|
|
* `c` (24): `data_length` variable. `min_final_cltv_expiry` to use for the |
|
|
* last HTLC in the route. Default is 9 if not specified. |
|
|
* last HTLC in the route. Default is 18 if not specified. |
|
|
*/ |
|
|
*/ |
|
|
#define DEFAULT_C 9 |
|
|
|
|
|
static char *decode_c(struct bolt11 *b11, |
|
|
static char *decode_c(struct bolt11 *b11, |
|
|
struct hash_u5 *hu5, |
|
|
struct hash_u5 *hu5, |
|
|
u5 **data, size_t *data_len, |
|
|
u5 **data, size_t *data_len, |
|
@ -536,7 +535,11 @@ struct bolt11 *new_bolt11(const tal_t *ctx, |
|
|
b11->msat = NULL; |
|
|
b11->msat = NULL; |
|
|
b11->expiry = DEFAULT_X; |
|
|
b11->expiry = DEFAULT_X; |
|
|
b11->features = tal_arr(b11, u8, 0); |
|
|
b11->features = tal_arr(b11, u8, 0); |
|
|
b11->min_final_cltv_expiry = DEFAULT_C; |
|
|
/* BOLT #11:
|
|
|
|
|
|
* - if the `c` field (`min_final_cltv_expiry`) is not provided: |
|
|
|
|
|
* - MUST use an expiry delta of at least 18 when making the payment |
|
|
|
|
|
*/ |
|
|
|
|
|
b11->min_final_cltv_expiry = 18; |
|
|
b11->payment_secret = NULL; |
|
|
b11->payment_secret = NULL; |
|
|
|
|
|
|
|
|
if (msat) |
|
|
if (msat) |
|
@ -861,8 +864,8 @@ static void push_field(u5 **data, char type, const void *src, size_t nbits) |
|
|
* |
|
|
* |
|
|
* - if `x` is included: |
|
|
* - if `x` is included: |
|
|
* - SHOULD use the minimum `data_length` possible. |
|
|
* - SHOULD use the minimum `data_length` possible. |
|
|
|
|
|
* - MUST include one `c` field (`min_final_cltv_expiry`). |
|
|
*... |
|
|
*... |
|
|
* - if `c` is included: |
|
|
|
|
|
* - SHOULD use the minimum `data_length` possible. |
|
|
* - SHOULD use the minimum `data_length` possible. |
|
|
*/ |
|
|
*/ |
|
|
static void push_varlen_field(u5 **data, char type, u64 val) |
|
|
static void push_varlen_field(u5 **data, char type, u64 val) |
|
@ -1095,8 +1098,10 @@ char *bolt11_encode_(const tal_t *ctx, |
|
|
if (b11->expiry != DEFAULT_X) |
|
|
if (b11->expiry != DEFAULT_X) |
|
|
encode_x(&data, b11->expiry); |
|
|
encode_x(&data, b11->expiry); |
|
|
|
|
|
|
|
|
if (b11->min_final_cltv_expiry != DEFAULT_C) |
|
|
/* BOLT #11:
|
|
|
encode_c(&data, b11->min_final_cltv_expiry); |
|
|
* - MUST include one `c` field (`min_final_cltv_expiry`). |
|
|
|
|
|
*/ |
|
|
|
|
|
encode_c(&data, b11->min_final_cltv_expiry); |
|
|
|
|
|
|
|
|
if (b11->payment_secret) |
|
|
if (b11->payment_secret) |
|
|
encode_s(&data, b11->payment_secret); |
|
|
encode_s(&data, b11->payment_secret); |
|
|