mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-28 14:40:51 +02:00
lnwire: store unknown address type as OpaqueAddrs
Instead of erroring out with encountering an address with an unknown type, we just store the remainder of the addrBytes as OpaqueAddrs so that we are able to rewrite them to the wire when we re-propagate the message.
This commit is contained in:
@@ -804,7 +804,29 @@ func ReadElement(r io.Reader, element interface{}) error {
|
||||
addrBytesRead += aType.AddrLen()
|
||||
|
||||
default:
|
||||
return &ErrUnknownAddrType{aType}
|
||||
// If we don't understand this address type,
|
||||
// we just store it along with the remaining
|
||||
// address bytes as type OpaqueAddrs. We need
|
||||
// to hold onto the bytes so that we can still
|
||||
// write them back to the wire when we
|
||||
// propagate this message.
|
||||
payloadLen := 1 + addrsLen - addrBytesRead
|
||||
payload := make([]byte, payloadLen)
|
||||
|
||||
// First write a byte for the address type that
|
||||
// we already read.
|
||||
payload[0] = byte(aType)
|
||||
|
||||
// Now append the rest of the address bytes.
|
||||
_, err := io.ReadFull(addrBuf, payload[1:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
address = &OpaqueAddrs{
|
||||
Payload: payload,
|
||||
}
|
||||
addrBytesRead = addrsLen
|
||||
}
|
||||
|
||||
addresses = append(addresses, address)
|
||||
|
Reference in New Issue
Block a user