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>
This commit is contained in:
Rusty Russell
2017-12-06 10:06:32 +10:30
parent 899bf3fde9
commit afea2520ba
2 changed files with 5 additions and 0 deletions

View File

@@ -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);

View File

@@ -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 */