Browse Source

wireaddr: marshal empty address properly.

On unmarshal, we stop unmarshaling on a 0 (ADDR_TYPE_PADDING) type.  So
we should also stop marshaling in that case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
afea2520ba
  1. 4
      common/wireaddr.c
  2. 1
      common/wireaddr.h

4
common/wireaddr.c

@ -28,6 +28,10 @@ bool fromwire_wireaddr(const u8 **cursor, size_t *max, struct wireaddr *addr)
void towire_wireaddr(u8 **pptr, const struct wireaddr *addr)
{
if (!addr || addr->type == ADDR_TYPE_PADDING) {
towire_u8(pptr, ADDR_TYPE_PADDING);
return;
}
towire_u8(pptr, addr->type);
towire(pptr, addr->addr, addr->addrlen);
towire_u16(pptr, addr->port);

1
common/wireaddr.h

@ -36,6 +36,7 @@ struct wireaddr {
u16 port;
};
/* Inserts a single ADDR_TYPE_PADDING if addr is NULL */
void towire_wireaddr(u8 **pptr, const struct wireaddr *addr);
bool fromwire_wireaddr(const u8 **cursor, size_t *max, struct wireaddr *addr);
#endif /* LIGHTNING_COMMON_WIREADDR_H */

Loading…
Cancel
Save