mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
Makefile: import latest spec, which includes quickclose.
It also gets rid of the requirement that close negotiation fee maximum is the old commitment transaction. We still do that, however, to avoid surprising old peers. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
fb4edc2938
commit
23a6c00496
9 changed files with 266 additions and 26 deletions
2
Makefile
2
Makefile
|
@ -24,7 +24,7 @@ CCANDIR := ccan
|
|||
|
||||
# Where we keep the BOLT RFCs
|
||||
BOLTDIR := ../lightning-rfc/
|
||||
DEFAULT_BOLTVERSION := fdc078f845e1e12069a0b881e95389b3a88c4ff7
|
||||
DEFAULT_BOLTVERSION := 498f104fd399488c77f449d05cb21c0b604636a2
|
||||
# Can be overridden on cmdline.
|
||||
BOLTVERSION := $(DEFAULT_BOLTVERSION)
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ static void send_offer(struct per_peer_state *pps,
|
|||
type_to_string(tmpctx, struct amount_sat, &fee_to_offer));
|
||||
|
||||
assert(our_sig.sighash_type == SIGHASH_ALL);
|
||||
msg = towire_closing_signed(NULL, channel_id, fee_to_offer, &our_sig.s);
|
||||
msg = towire_closing_signed(NULL, channel_id, fee_to_offer, &our_sig.s, NULL);
|
||||
sync_crypto_write(pps, take(msg));
|
||||
}
|
||||
|
||||
|
@ -229,6 +229,7 @@ receive_offer(struct per_peer_state *pps,
|
|||
struct amount_sat received_fee;
|
||||
struct bitcoin_signature their_sig;
|
||||
struct bitcoin_tx *tx;
|
||||
struct tlv_closing_signed_tlvs *close_tlvs;
|
||||
|
||||
/* Wait for them to say something interesting */
|
||||
do {
|
||||
|
@ -252,8 +253,10 @@ receive_offer(struct per_peer_state *pps,
|
|||
} while (!msg);
|
||||
|
||||
their_sig.sighash_type = SIGHASH_ALL;
|
||||
close_tlvs = tlv_closing_signed_tlvs_new(msg);
|
||||
if (!fromwire_closing_signed(msg, &their_channel_id,
|
||||
&received_fee, &their_sig.s))
|
||||
&received_fee, &their_sig.s,
|
||||
close_tlvs))
|
||||
peer_failed_warn(pps, channel_id,
|
||||
"Expected closing_signed: %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
|
@ -347,7 +350,8 @@ static void init_feerange(struct feerange *feerange,
|
|||
{
|
||||
feerange->min = AMOUNT_SAT(0);
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME: BOLT 2 previously said that we have to set it to less than
|
||||
* the final commit fee: we do this for now, still:
|
||||
*
|
||||
* - MUST set `fee_satoshis` less than or equal to the base
|
||||
* fee of the final commitment transaction, as calculated
|
||||
|
@ -371,7 +375,8 @@ static void adjust_feerange(struct feerange *feerange,
|
|||
{
|
||||
bool ok;
|
||||
|
||||
/* BOLT #2:
|
||||
/* FIXME: BOLT 2 previously said that we have to set it to less than
|
||||
* the final commit fee: we do this for now, still:
|
||||
*
|
||||
* - MUST propose a value "strictly between" the received
|
||||
* `fee_satoshis` and its previously-sent `fee_satoshis`.
|
||||
|
|
|
@ -147,14 +147,18 @@ wallet_commit_channel(struct lightningd *ld,
|
|||
* #### Requirements
|
||||
*
|
||||
* Both peers:
|
||||
* - if `option_static_remotekey`, `option_anchor_outputs` or
|
||||
* `option_anchors_zero_fee_htlc_tx` was negotiated:
|
||||
* - `option_static_remotekey`, `option_anchor_outputs` or
|
||||
* `option_anchors_zero_fee_htlc_tx` applies to all commitment transactions
|
||||
* ...
|
||||
* - if `option_anchors_zero_fee_htlc_tx` was negotiated:
|
||||
* - the `channel_type` is `option_anchors_zero_fee_htlc_tx` and
|
||||
* `option_static_remotekey` (bits 22 and 12)
|
||||
* - otherwise, if `option_anchor_outputs` was negotiated:
|
||||
* - the `channel_type` is `option_anchor_outputs` and
|
||||
* `option_static_remotekey` (bits 20 and 12)
|
||||
* - otherwise, if `option_static_remotekey` was negotiated:
|
||||
* - the `channel_type` is `option_static_remotekey` (bit 12)
|
||||
* - otherwise:
|
||||
* - `option_static_remotekey`, `option_anchor_outputs` or
|
||||
* `option_anchors_zero_fee_htlc_tx` does not apply to any commitment
|
||||
* transactions
|
||||
* - the `channel_type` is empty
|
||||
* - MUST use that `channel_type` for all commitment transactions.
|
||||
*/
|
||||
/* i.e. We set it now for the channel permanently. */
|
||||
if (feature_negotiated(ld->our_features,
|
||||
|
|
62
wire/peer_printgen.c
generated
62
wire/peer_printgen.c
generated
|
@ -470,10 +470,24 @@ static void printwire_tlv_open_channel_tlvs_upfront_shutdown_script(const char *
|
|||
return;
|
||||
}
|
||||
|
||||
}
|
||||
static void printwire_tlv_open_channel_tlvs_channel_type(const char *fieldname, const u8 **cursor, size_t *plen)
|
||||
{
|
||||
printf("(msg_name=%s)\n", "channel_type");
|
||||
|
||||
printf("type=");
|
||||
printwire_u8_array(tal_fmt(NULL, "%s.type", fieldname), cursor, plen, *plen);
|
||||
|
||||
if (!*cursor) {
|
||||
printf("**TRUNCATED**\n");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const struct tlv_print_record_type print_tlvs_open_channel_tlvs[] = {
|
||||
{ 0, printwire_tlv_open_channel_tlvs_upfront_shutdown_script },
|
||||
{ 1, printwire_tlv_open_channel_tlvs_channel_type },
|
||||
};
|
||||
|
||||
static void printwire_tlv_accept_channel_tlvs_upfront_shutdown_script(const char *fieldname, const u8 **cursor, size_t *plen)
|
||||
|
@ -488,10 +502,24 @@ static void printwire_tlv_accept_channel_tlvs_upfront_shutdown_script(const char
|
|||
return;
|
||||
}
|
||||
|
||||
}
|
||||
static void printwire_tlv_accept_channel_tlvs_channel_type(const char *fieldname, const u8 **cursor, size_t *plen)
|
||||
{
|
||||
printf("(msg_name=%s)\n", "channel_type");
|
||||
|
||||
printf("type=");
|
||||
printwire_u8_array(tal_fmt(NULL, "%s.type", fieldname), cursor, plen, *plen);
|
||||
|
||||
if (!*cursor) {
|
||||
printf("**TRUNCATED**\n");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const struct tlv_print_record_type print_tlvs_accept_channel_tlvs[] = {
|
||||
{ 0, printwire_tlv_accept_channel_tlvs_upfront_shutdown_script },
|
||||
{ 1, printwire_tlv_accept_channel_tlvs_channel_type },
|
||||
};
|
||||
|
||||
static void printwire_tlv_opening_tlvs_option_upfront_shutdown_script(const char *fieldname, const u8 **cursor, size_t *plen)
|
||||
|
@ -611,6 +639,33 @@ static const struct tlv_print_record_type print_tlvs_shutdown_tlvs[] = {
|
|||
{ 100, printwire_tlv_shutdown_tlvs_wrong_funding },
|
||||
};
|
||||
|
||||
static void printwire_tlv_closing_signed_tlvs_fee_range(const char *fieldname, const u8 **cursor, size_t *plen)
|
||||
{
|
||||
printf("(msg_name=%s)\n", "fee_range");
|
||||
|
||||
printf("min_fee_satoshis=");
|
||||
struct amount_sat min_fee_satoshis = fromwire_amount_sat(cursor, plen);
|
||||
|
||||
printwire_amount_sat(tal_fmt(NULL, "%s.min_fee_satoshis", fieldname), &min_fee_satoshis);
|
||||
if (!*cursor) {
|
||||
printf("**TRUNCATED**\n");
|
||||
return;
|
||||
}
|
||||
printf("max_fee_satoshis=");
|
||||
struct amount_sat max_fee_satoshis = fromwire_amount_sat(cursor, plen);
|
||||
|
||||
printwire_amount_sat(tal_fmt(NULL, "%s.max_fee_satoshis", fieldname), &max_fee_satoshis);
|
||||
if (!*cursor) {
|
||||
printf("**TRUNCATED**\n");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const struct tlv_print_record_type print_tlvs_closing_signed_tlvs[] = {
|
||||
{ 1, printwire_tlv_closing_signed_tlvs_fee_range },
|
||||
};
|
||||
|
||||
static void printwire_tlv_node_ann_tlvs_option_will_fund(const char *fieldname, const u8 **cursor, size_t *plen)
|
||||
{
|
||||
printf("(msg_name=%s)\n", "option_will_fund");
|
||||
|
@ -2032,6 +2087,8 @@ void printwire_closing_signed(const char *fieldname, const u8 *cursor)
|
|||
printf("**TRUNCATED**\n");
|
||||
return;
|
||||
}
|
||||
printf("tlvs=");
|
||||
printwire_tlvs(tal_fmt(NULL, "%s.tlvs", fieldname), &cursor, &plen, print_tlvs_closing_signed_tlvs, ARRAY_SIZE(print_tlvs_closing_signed_tlvs));
|
||||
|
||||
|
||||
if (plen != 0)
|
||||
|
@ -3063,6 +3120,9 @@ void printpeer_wire_tlv_message(const char *tlv_name, const u8 *msg) {
|
|||
if (strcmp(tlv_name, "shutdown_tlvs") == 0) {
|
||||
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_shutdown_tlvs, ARRAY_SIZE(print_tlvs_shutdown_tlvs));
|
||||
}
|
||||
if (strcmp(tlv_name, "closing_signed_tlvs") == 0) {
|
||||
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_closing_signed_tlvs, ARRAY_SIZE(print_tlvs_closing_signed_tlvs));
|
||||
}
|
||||
if (strcmp(tlv_name, "node_ann_tlvs") == 0) {
|
||||
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_node_ann_tlvs, ARRAY_SIZE(print_tlvs_node_ann_tlvs));
|
||||
}
|
||||
|
@ -3079,4 +3139,4 @@ void printpeer_wire_tlv_message(const char *tlv_name, const u8 *msg) {
|
|||
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_onion_message_tlvs, ARRAY_SIZE(print_tlvs_onion_message_tlvs));
|
||||
}
|
||||
}
|
||||
// SHA256STAMP:7acdb2f85dec7c26fb60ae3302f387fbccae349e182d05c6e4bb043ce2546797
|
||||
// SHA256STAMP:c55c98a2d8cac53c9f0db9ca4eb5ef1caac507e2f7cf4d1988cfc548efe40bbf
|
||||
|
|
2
wire/peer_printgen.h
generated
2
wire/peer_printgen.h
generated
|
@ -99,4 +99,4 @@ void printwire_channel_update_checksums(const char *fieldname, const u8 **cursor
|
|||
void printwire_channel_update_timestamps(const char *fieldname, const u8 **cursor, size_t *plen);
|
||||
void printwire_witness_stack(const char *fieldname, const u8 **cursor, size_t *plen);
|
||||
#endif /* LIGHTNING_WIRE_PEER_PRINTGEN_H */
|
||||
// SHA256STAMP:7acdb2f85dec7c26fb60ae3302f387fbccae349e182d05c6e4bb043ce2546797
|
||||
// SHA256STAMP:c55c98a2d8cac53c9f0db9ca4eb5ef1caac507e2f7cf4d1988cfc548efe40bbf
|
||||
|
|
|
@ -91,6 +91,8 @@ msgdata,open_channel,channel_flags,byte,
|
|||
msgdata,open_channel,tlvs,open_channel_tlvs,
|
||||
tlvtype,open_channel_tlvs,upfront_shutdown_script,0
|
||||
tlvdata,open_channel_tlvs,upfront_shutdown_script,shutdown_scriptpubkey,byte,...
|
||||
tlvtype,open_channel_tlvs,channel_type,1
|
||||
tlvdata,open_channel_tlvs,channel_type,type,byte,...
|
||||
msgtype,accept_channel,33
|
||||
msgdata,accept_channel,temporary_channel_id,byte,32
|
||||
msgdata,accept_channel,dust_limit_satoshis,u64,
|
||||
|
@ -109,6 +111,8 @@ msgdata,accept_channel,first_per_commitment_point,point,
|
|||
msgdata,accept_channel,tlvs,accept_channel_tlvs,
|
||||
tlvtype,accept_channel_tlvs,upfront_shutdown_script,0
|
||||
tlvdata,accept_channel_tlvs,upfront_shutdown_script,shutdown_scriptpubkey,byte,...
|
||||
tlvtype,accept_channel_tlvs,channel_type,1
|
||||
tlvdata,accept_channel_tlvs,channel_type,type,byte,...
|
||||
msgtype,funding_created,34
|
||||
msgdata,funding_created,temporary_channel_id,byte,32
|
||||
msgdata,funding_created,funding_txid,sha256,
|
||||
|
@ -194,6 +198,10 @@ msgtype,closing_signed,39
|
|||
msgdata,closing_signed,channel_id,channel_id,
|
||||
msgdata,closing_signed,fee_satoshis,u64,
|
||||
msgdata,closing_signed,signature,signature,
|
||||
msgdata,closing_signed,tlvs,closing_signed_tlvs,
|
||||
tlvtype,closing_signed_tlvs,fee_range,1
|
||||
tlvdata,closing_signed_tlvs,fee_range,min_fee_satoshis,u64,
|
||||
tlvdata,closing_signed_tlvs,fee_range,max_fee_satoshis,u64,
|
||||
msgtype,update_add_htlc,128
|
||||
msgdata,update_add_htlc,channel_id,channel_id,
|
||||
msgdata,update_add_htlc,id,u64,
|
||||
|
|
|
119
wire/peer_wiregen.c
generated
119
wire/peer_wiregen.c
generated
|
@ -517,20 +517,43 @@ static void fromwire_tlv_open_channel_tlvs_upfront_shutdown_script(const u8 **cu
|
|||
r->upfront_shutdown_script = tal_arr(r, u8, *plen);
|
||||
fromwire_u8_array(cursor, plen, r->upfront_shutdown_script, *plen);
|
||||
}
|
||||
/* OPEN_CHANNEL_TLVS MSG: channel_type */
|
||||
static u8 *towire_tlv_open_channel_tlvs_channel_type(const tal_t *ctx, const void *vrecord)
|
||||
{
|
||||
const struct tlv_open_channel_tlvs *r = vrecord;
|
||||
u8 *ptr;
|
||||
|
||||
if (!r->channel_type)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr = tal_arr(ctx, u8, 0);
|
||||
|
||||
towire_u8_array(&ptr, r->channel_type, tal_count(r->channel_type));
|
||||
return ptr;
|
||||
}
|
||||
static void fromwire_tlv_open_channel_tlvs_channel_type(const u8 **cursor, size_t *plen, void *vrecord)
|
||||
{
|
||||
struct tlv_open_channel_tlvs *r = vrecord;
|
||||
|
||||
r->channel_type = tal_arr(r, u8, *plen);
|
||||
fromwire_u8_array(cursor, plen, r->channel_type, *plen);
|
||||
}
|
||||
|
||||
static const struct tlv_record_type tlvs_open_channel_tlvs[] = {
|
||||
{ 0, towire_tlv_open_channel_tlvs_upfront_shutdown_script, fromwire_tlv_open_channel_tlvs_upfront_shutdown_script },
|
||||
{ 1, towire_tlv_open_channel_tlvs_channel_type, fromwire_tlv_open_channel_tlvs_channel_type },
|
||||
};
|
||||
|
||||
void towire_open_channel_tlvs(u8 **pptr, const struct tlv_open_channel_tlvs *record)
|
||||
{
|
||||
towire_tlv(pptr, tlvs_open_channel_tlvs, 1, record);
|
||||
towire_tlv(pptr, tlvs_open_channel_tlvs, 2, record);
|
||||
}
|
||||
|
||||
|
||||
bool fromwire_open_channel_tlvs(const u8 **cursor, size_t *max, struct tlv_open_channel_tlvs *record)
|
||||
{
|
||||
return fromwire_tlv(cursor, max, tlvs_open_channel_tlvs, 1, record, &record->fields);
|
||||
return fromwire_tlv(cursor, max, tlvs_open_channel_tlvs, 2, record, &record->fields);
|
||||
}
|
||||
|
||||
bool open_channel_tlvs_is_valid(const struct tlv_open_channel_tlvs *record, size_t *err_index)
|
||||
|
@ -571,20 +594,43 @@ static void fromwire_tlv_accept_channel_tlvs_upfront_shutdown_script(const u8 **
|
|||
r->upfront_shutdown_script = tal_arr(r, u8, *plen);
|
||||
fromwire_u8_array(cursor, plen, r->upfront_shutdown_script, *plen);
|
||||
}
|
||||
/* ACCEPT_CHANNEL_TLVS MSG: channel_type */
|
||||
static u8 *towire_tlv_accept_channel_tlvs_channel_type(const tal_t *ctx, const void *vrecord)
|
||||
{
|
||||
const struct tlv_accept_channel_tlvs *r = vrecord;
|
||||
u8 *ptr;
|
||||
|
||||
if (!r->channel_type)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr = tal_arr(ctx, u8, 0);
|
||||
|
||||
towire_u8_array(&ptr, r->channel_type, tal_count(r->channel_type));
|
||||
return ptr;
|
||||
}
|
||||
static void fromwire_tlv_accept_channel_tlvs_channel_type(const u8 **cursor, size_t *plen, void *vrecord)
|
||||
{
|
||||
struct tlv_accept_channel_tlvs *r = vrecord;
|
||||
|
||||
r->channel_type = tal_arr(r, u8, *plen);
|
||||
fromwire_u8_array(cursor, plen, r->channel_type, *plen);
|
||||
}
|
||||
|
||||
static const struct tlv_record_type tlvs_accept_channel_tlvs[] = {
|
||||
{ 0, towire_tlv_accept_channel_tlvs_upfront_shutdown_script, fromwire_tlv_accept_channel_tlvs_upfront_shutdown_script },
|
||||
{ 1, towire_tlv_accept_channel_tlvs_channel_type, fromwire_tlv_accept_channel_tlvs_channel_type },
|
||||
};
|
||||
|
||||
void towire_accept_channel_tlvs(u8 **pptr, const struct tlv_accept_channel_tlvs *record)
|
||||
{
|
||||
towire_tlv(pptr, tlvs_accept_channel_tlvs, 1, record);
|
||||
towire_tlv(pptr, tlvs_accept_channel_tlvs, 2, record);
|
||||
}
|
||||
|
||||
|
||||
bool fromwire_accept_channel_tlvs(const u8 **cursor, size_t *max, struct tlv_accept_channel_tlvs *record)
|
||||
{
|
||||
return fromwire_tlv(cursor, max, tlvs_accept_channel_tlvs, 1, record, &record->fields);
|
||||
return fromwire_tlv(cursor, max, tlvs_accept_channel_tlvs, 2, record, &record->fields);
|
||||
}
|
||||
|
||||
bool accept_channel_tlvs_is_valid(const struct tlv_accept_channel_tlvs *record, size_t *err_index)
|
||||
|
@ -822,6 +868,63 @@ bool shutdown_tlvs_is_valid(const struct tlv_shutdown_tlvs *record, size_t *err_
|
|||
}
|
||||
|
||||
|
||||
struct tlv_closing_signed_tlvs *tlv_closing_signed_tlvs_new(const tal_t *ctx)
|
||||
{
|
||||
/* Initialize everything to NULL. (Quiet, C pedants!) */
|
||||
struct tlv_closing_signed_tlvs *inst = talz(ctx, struct tlv_closing_signed_tlvs);
|
||||
|
||||
/* Initialized the fields to an empty array. */
|
||||
inst->fields = tal_arr(inst, struct tlv_field, 0);
|
||||
return inst;
|
||||
}
|
||||
|
||||
/* CLOSING_SIGNED_TLVS MSG: fee_range */
|
||||
static u8 *towire_tlv_closing_signed_tlvs_fee_range(const tal_t *ctx, const void *vrecord)
|
||||
{
|
||||
const struct tlv_closing_signed_tlvs *r = vrecord;
|
||||
u8 *ptr;
|
||||
|
||||
if (!r->fee_range)
|
||||
return NULL;
|
||||
|
||||
|
||||
ptr = tal_arr(ctx, u8, 0);
|
||||
|
||||
towire_amount_sat(&ptr, r->fee_range->min_fee_satoshis);
|
||||
|
||||
towire_amount_sat(&ptr, r->fee_range->max_fee_satoshis);
|
||||
return ptr;
|
||||
}
|
||||
static void fromwire_tlv_closing_signed_tlvs_fee_range(const u8 **cursor, size_t *plen, void *vrecord)
|
||||
{
|
||||
struct tlv_closing_signed_tlvs *r = vrecord;
|
||||
|
||||
r->fee_range = tal(r, struct tlv_closing_signed_tlvs_fee_range);
|
||||
r->fee_range->min_fee_satoshis = fromwire_amount_sat(cursor, plen);
|
||||
r->fee_range->max_fee_satoshis = fromwire_amount_sat(cursor, plen);
|
||||
}
|
||||
|
||||
static const struct tlv_record_type tlvs_closing_signed_tlvs[] = {
|
||||
{ 1, towire_tlv_closing_signed_tlvs_fee_range, fromwire_tlv_closing_signed_tlvs_fee_range },
|
||||
};
|
||||
|
||||
void towire_closing_signed_tlvs(u8 **pptr, const struct tlv_closing_signed_tlvs *record)
|
||||
{
|
||||
towire_tlv(pptr, tlvs_closing_signed_tlvs, 1, record);
|
||||
}
|
||||
|
||||
|
||||
bool fromwire_closing_signed_tlvs(const u8 **cursor, size_t *max, struct tlv_closing_signed_tlvs *record)
|
||||
{
|
||||
return fromwire_tlv(cursor, max, tlvs_closing_signed_tlvs, 1, record, &record->fields);
|
||||
}
|
||||
|
||||
bool closing_signed_tlvs_is_valid(const struct tlv_closing_signed_tlvs *record, size_t *err_index)
|
||||
{
|
||||
return tlv_fields_valid(record->fields, NULL, err_index);
|
||||
}
|
||||
|
||||
|
||||
struct tlv_node_ann_tlvs *tlv_node_ann_tlvs_new(const tal_t *ctx)
|
||||
{
|
||||
/* Initialize everything to NULL. (Quiet, C pedants!) */
|
||||
|
@ -1834,7 +1937,7 @@ bool fromwire_shutdown(const tal_t *ctx, const void *p, struct channel_id *chann
|
|||
}
|
||||
|
||||
/* WIRE: CLOSING_SIGNED */
|
||||
u8 *towire_closing_signed(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat fee_satoshis, const secp256k1_ecdsa_signature *signature)
|
||||
u8 *towire_closing_signed(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat fee_satoshis, const secp256k1_ecdsa_signature *signature, const struct tlv_closing_signed_tlvs *tlvs)
|
||||
{
|
||||
u8 *p = tal_arr(ctx, u8, 0);
|
||||
|
||||
|
@ -1842,10 +1945,11 @@ u8 *towire_closing_signed(const tal_t *ctx, const struct channel_id *channel_id,
|
|||
towire_channel_id(&p, channel_id);
|
||||
towire_amount_sat(&p, fee_satoshis);
|
||||
towire_secp256k1_ecdsa_signature(&p, signature);
|
||||
towire_closing_signed_tlvs(&p, tlvs);
|
||||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_closing_signed(const void *p, struct channel_id *channel_id, struct amount_sat *fee_satoshis, secp256k1_ecdsa_signature *signature)
|
||||
bool fromwire_closing_signed(const void *p, struct channel_id *channel_id, struct amount_sat *fee_satoshis, secp256k1_ecdsa_signature *signature, struct tlv_closing_signed_tlvs *tlvs)
|
||||
{
|
||||
const u8 *cursor = p;
|
||||
size_t plen = tal_count(p);
|
||||
|
@ -1855,6 +1959,7 @@ bool fromwire_closing_signed(const void *p, struct channel_id *channel_id, struc
|
|||
fromwire_channel_id(&cursor, &plen, channel_id);
|
||||
*fee_satoshis = fromwire_amount_sat(&cursor, &plen);
|
||||
fromwire_secp256k1_ecdsa_signature(&cursor, &plen, signature);
|
||||
fromwire_closing_signed_tlvs(&cursor, &plen, tlvs);
|
||||
return cursor != NULL;
|
||||
}
|
||||
|
||||
|
@ -2484,4 +2589,4 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p, secp256k1_ec
|
|||
*htlc_maximum_msat = fromwire_amount_msat(&cursor, &plen);
|
||||
return cursor != NULL;
|
||||
}
|
||||
// SHA256STAMP:7acdb2f85dec7c26fb60ae3302f387fbccae349e182d05c6e4bb043ce2546797
|
||||
// SHA256STAMP:c55c98a2d8cac53c9f0db9ca4eb5ef1caac507e2f7cf4d1988cfc548efe40bbf
|
||||
|
|
57
wire/peer_wiregen.h
generated
57
wire/peer_wiregen.h
generated
|
@ -115,6 +115,10 @@ struct tlv_shutdown_tlvs_wrong_funding {
|
|||
struct bitcoin_txid txid;
|
||||
u32 outnum;
|
||||
};
|
||||
struct tlv_closing_signed_tlvs_fee_range {
|
||||
struct amount_sat min_fee_satoshis;
|
||||
struct amount_sat max_fee_satoshis;
|
||||
};
|
||||
struct tlv_query_short_channel_ids_tlvs_query_flags {
|
||||
u8 encoding_type;
|
||||
u8 *encoded_query_flags;
|
||||
|
@ -158,6 +162,7 @@ struct tlv_open_channel_tlvs {
|
|||
/* TODO The following explicit fields could just point into the
|
||||
* tlv_field entries above to save on memory. */
|
||||
u8 *upfront_shutdown_script;
|
||||
u8 *channel_type;
|
||||
};
|
||||
struct tlv_accept_channel_tlvs {
|
||||
/* Raw fields including unknown ones. */
|
||||
|
@ -166,6 +171,7 @@ struct tlv_accept_channel_tlvs {
|
|||
/* TODO The following explicit fields could just point into the
|
||||
* tlv_field entries above to save on memory. */
|
||||
u8 *upfront_shutdown_script;
|
||||
u8 *channel_type;
|
||||
};
|
||||
struct tlv_opening_tlvs {
|
||||
/* Raw fields including unknown ones. */
|
||||
|
@ -193,6 +199,14 @@ struct tlv_shutdown_tlvs {
|
|||
* tlv_field entries above to save on memory. */
|
||||
struct tlv_shutdown_tlvs_wrong_funding *wrong_funding;
|
||||
};
|
||||
struct tlv_closing_signed_tlvs {
|
||||
/* Raw fields including unknown ones. */
|
||||
struct tlv_field *fields;
|
||||
|
||||
/* TODO The following explicit fields could just point into the
|
||||
* tlv_field entries above to save on memory. */
|
||||
struct tlv_closing_signed_tlvs_fee_range *fee_range;
|
||||
};
|
||||
struct tlv_node_ann_tlvs {
|
||||
/* Raw fields including unknown ones. */
|
||||
struct tlv_field *fields;
|
||||
|
@ -555,6 +569,43 @@ void towire_shutdown_tlvs(u8 **pptr, const struct tlv_shutdown_tlvs *record);
|
|||
bool shutdown_tlvs_is_valid(const struct tlv_shutdown_tlvs *record,
|
||||
size_t *err_index);
|
||||
|
||||
struct tlv_closing_signed_tlvs *tlv_closing_signed_tlvs_new(const tal_t *ctx);
|
||||
|
||||
/**
|
||||
* Deserialize a TLV stream for the closing_signed_tlvs namespace.
|
||||
*
|
||||
* This function will parse any TLV stream, as long as the type, length and
|
||||
* value fields are formatted correctly. Fields that are not known in the
|
||||
* current namespace are stored in the `fields` member. Validity can be
|
||||
* checked using closing_signed_tlvs_is_valid.
|
||||
*/
|
||||
bool fromwire_closing_signed_tlvs(const u8 **cursor, size_t *max,
|
||||
struct tlv_closing_signed_tlvs * record);
|
||||
|
||||
/**
|
||||
* Serialize a TLV stream for the closing_signed_tlvs namespace.
|
||||
*
|
||||
* This function only considers known fields from the closing_signed_tlvs namespace,
|
||||
* and will ignore any fields that may be stored in the `fields` member. This
|
||||
* ensures that the resulting stream is valid according to
|
||||
* `closing_signed_tlvs_is_valid`.
|
||||
*/
|
||||
void towire_closing_signed_tlvs(u8 **pptr, const struct tlv_closing_signed_tlvs *record);
|
||||
|
||||
/**
|
||||
* Check that the TLV stream is valid.
|
||||
*
|
||||
* Enforces the followin validity rules:
|
||||
* - Types must be in monotonic non-repeating order
|
||||
* - We must understand all even types
|
||||
*
|
||||
* Returns false if an error was detected, otherwise returns true. If err_index
|
||||
* is non-null and we detect an error it is set to the index of the first error
|
||||
* detected.
|
||||
*/
|
||||
bool closing_signed_tlvs_is_valid(const struct tlv_closing_signed_tlvs *record,
|
||||
size_t *err_index);
|
||||
|
||||
struct tlv_node_ann_tlvs *tlv_node_ann_tlvs_new(const tal_t *ctx);
|
||||
|
||||
/**
|
||||
|
@ -845,8 +896,8 @@ u8 *towire_shutdown(const tal_t *ctx, const struct channel_id *channel_id, const
|
|||
bool fromwire_shutdown(const tal_t *ctx, const void *p, struct channel_id *channel_id, u8 **scriptpubkey, struct tlv_shutdown_tlvs *tlvs);
|
||||
|
||||
/* WIRE: CLOSING_SIGNED */
|
||||
u8 *towire_closing_signed(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat fee_satoshis, const secp256k1_ecdsa_signature *signature);
|
||||
bool fromwire_closing_signed(const void *p, struct channel_id *channel_id, struct amount_sat *fee_satoshis, secp256k1_ecdsa_signature *signature);
|
||||
u8 *towire_closing_signed(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat fee_satoshis, const secp256k1_ecdsa_signature *signature, const struct tlv_closing_signed_tlvs *tlvs);
|
||||
bool fromwire_closing_signed(const void *p, struct channel_id *channel_id, struct amount_sat *fee_satoshis, secp256k1_ecdsa_signature *signature, struct tlv_closing_signed_tlvs *tlvs);
|
||||
|
||||
/* WIRE: UPDATE_ADD_HTLC */
|
||||
u8 *towire_update_add_htlc(const tal_t *ctx, const struct channel_id *channel_id, u64 id, struct amount_msat amount_msat, const struct sha256 *payment_hash, u32 cltv_expiry, const u8 onion_routing_packet[1366]);
|
||||
|
@ -930,4 +981,4 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p, secp256k1_ec
|
|||
|
||||
|
||||
#endif /* LIGHTNING_WIRE_PEER_WIREGEN_H */
|
||||
// SHA256STAMP:7acdb2f85dec7c26fb60ae3302f387fbccae349e182d05c6e4bb043ce2546797
|
||||
// SHA256STAMP:c55c98a2d8cac53c9f0db9ca4eb5ef1caac507e2f7cf4d1988cfc548efe40bbf
|
||||
|
|
|
@ -615,20 +615,27 @@ static struct msg_funding_signed *fromwire_struct_funding_signed(const tal_t *ct
|
|||
static void *towire_struct_closing_signed(const tal_t *ctx,
|
||||
const struct msg_closing_signed *s)
|
||||
{
|
||||
struct tlv_closing_signed_tlvs *close_tlvs;
|
||||
|
||||
close_tlvs = tlv_closing_signed_tlvs_new(ctx);
|
||||
return towire_closing_signed(ctx,
|
||||
&s->channel_id,
|
||||
s->fee_satoshis,
|
||||
&s->signature);
|
||||
&s->signature,
|
||||
close_tlvs);
|
||||
}
|
||||
|
||||
static struct msg_closing_signed *fromwire_struct_closing_signed(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_closing_signed *s = tal(ctx, struct msg_closing_signed);
|
||||
struct tlv_closing_signed_tlvs *close_tlvs;
|
||||
|
||||
close_tlvs = tlv_closing_signed_tlvs_new(ctx);
|
||||
if (fromwire_closing_signed(p,
|
||||
&s->channel_id,
|
||||
&s->fee_satoshis,
|
||||
&s->signature))
|
||||
&s->signature,
|
||||
close_tlvs))
|
||||
return s;
|
||||
return tal_free(s);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue