Skip to content

Commit 4e925f3

Browse files
committed
f - use more compact representation
1 parent 7cbf976 commit 4e925f3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lightning/src/offers/invoice_request.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1150,10 +1150,10 @@ impl Writeable for InvoiceRequestFields {
11501150
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
11511151
write_tlv_fields!(writer, {
11521152
(0, self.payer_id, required),
1153-
(2, self.amount_msats, option),
1153+
(2, self.amount_msats.map(|v| HighZeroBytesDroppedBigSize(v)), option),
11541154
(4, WithoutLength(&self.features), required),
1155-
(6, self.quantity, option),
1156-
(8, self.payer_note_truncated, option),
1155+
(6, self.quantity.map(|v| HighZeroBytesDroppedBigSize(v)), option),
1156+
(8, self.payer_note_truncated.as_ref().map(|s| WithoutLength(&s.0)), option),
11571157
});
11581158
Ok(())
11591159
}
@@ -1163,15 +1163,16 @@ impl Readable for InvoiceRequestFields {
11631163
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
11641164
_init_and_read_len_prefixed_tlv_fields!(reader, {
11651165
(0, payer_id, required),
1166-
(2, amount_msats, option),
1166+
(2, amount_msats, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
11671167
(4, features, (option, encoding: (InvoiceRequestFeatures, WithoutLength))),
1168-
(6, quantity, option),
1169-
(8, payer_note_truncated, option),
1168+
(6, quantity, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
1169+
(8, payer_note_truncated, (option, encoding: (String, WithoutLength))),
11701170
});
11711171
let features = features.unwrap_or(InvoiceRequestFeatures::empty());
11721172

11731173
Ok(InvoiceRequestFields {
1174-
payer_id: payer_id.0.unwrap(), amount_msats, features, quantity, payer_note_truncated,
1174+
payer_id: payer_id.0.unwrap(), amount_msats, features, quantity,
1175+
payer_note_truncated: payer_note_truncated.map(|s| UntrustedString(s)),
11751176
})
11761177
}
11771178
}

0 commit comments

Comments
 (0)