mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-03 05:04:21 +01:00
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:
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user