Browse Source

wire: handle bigsize/varint fields.

They're currently called varint, but there's a proposal to call them all
bigsize.  Allow both for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pull/2938/head
Rusty Russell 5 years ago
committed by neil saitug
parent
commit
c580225c38
  1. 7
      devtools/print_wire.h
  2. 4
      tools/generate-wire.py
  3. 6
      wire/wire.h

7
devtools/print_wire.h

@ -10,6 +10,13 @@ struct tlv_print_record_type {
void (*print)(const char *tlv_name, const u8 **cursor, size_t *plen); void (*print)(const char *tlv_name, const u8 **cursor, size_t *plen);
}; };
typedef u64 bigsize;
#define printwire_bigsize printwire_u64
/* FIXME: Some versions of spec using 'varint' for bigsize' */
typedef bigsize varint;
#define printwire_varint printwire_bigsize
void printwire_u8(const char *fieldname, const u8 *v); void printwire_u8(const char *fieldname, const u8 *v);
void printwire_u16(const char *fieldname, const u16 *v); void printwire_u16(const char *fieldname, const u16 *v);
void printwire_u32(const char *fieldname, const u32 *v); void printwire_u32(const char *fieldname, const u32 *v);

4
tools/generate-wire.py

@ -160,6 +160,8 @@ class Type(FieldSet):
'bool', 'bool',
'amount_sat', 'amount_sat',
'amount_msat', 'amount_msat',
'bigsize',
'varint'
] ]
typedefs = [ typedefs = [
@ -172,6 +174,8 @@ class Type(FieldSet):
'secp256k1_ecdsa_recoverable_signature', 'secp256k1_ecdsa_recoverable_signature',
'wirestring', 'wirestring',
'double', 'double',
'bigsize',
'varint',
] ]
truncated_typedefs = [ truncated_typedefs = [

6
wire/wire.h

@ -31,6 +31,12 @@ struct siphash_seed;
/* Makes generate-wire.py work */ /* Makes generate-wire.py work */
typedef char wirestring; typedef char wirestring;
typedef u64 bigsize;
/* FIXME: Some versions of spec using 'varint' for bigsize' */
typedef bigsize varint;
#define fromwire_varint fromwire_bigsize
#define towire_varint towire_bigsize
void derive_channel_id(struct channel_id *channel_id, void derive_channel_id(struct channel_id *channel_id,
const struct bitcoin_txid *txid, u16 txout); const struct bitcoin_txid *txid, u16 txout);

Loading…
Cancel
Save