Skip to content

Commit b651e5b

Browse files
Offers with currency must set amount. (#3140)
Adds check and corresponding test from lightning/bolts#1279
1 parent 5703cd4 commit b651e5b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/OfferTypes.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ object OfferTypes {
309309
def validate(records: TlvStream[OfferTlv]): Either[InvalidTlvPayload, Offer] = {
310310
if (records.get[OfferDescription].isEmpty && records.get[OfferAmount].nonEmpty) return Left(MissingRequiredTlv(UInt64(10)))
311311
if (records.get[OfferNodeId].isEmpty && records.get[OfferPaths].forall(_.paths.isEmpty)) return Left(MissingRequiredTlv(UInt64(22)))
312+
if (records.get[OfferCurrency].nonEmpty && records.get[OfferAmount].isEmpty) return Left(MissingRequiredTlv(UInt64(8)))
312313
if (records.unknown.exists(!isOfferTlv(_))) return Left(ForbiddenTlv(records.unknown.find(!isOfferTlv(_)).get.tag))
313314
Right(Offer(records))
314315
}

eclair-core/src/test/resources/offers-test.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,11 @@
578578
"valid": false,
579579
"bolt12": "lno1pqpzwyqkyypwa3eyt44h6txtxquqh7lz5djge4afgfjn7k4rgrkuag0jsd5xvxg"
580580
},
581+
{
582+
"description": "Missing offer_amount with offer_currency",
583+
"valid": false,
584+
"bolt12": "lno1qcp4256ypgx9getnwss8vetrw3hhyuckyypwa3eyt44h6txtxquqh7lz5djge4afgfjn7k4rgrkuag0jsd5xvxg"
585+
},
581586
{
582587
"description": "Missing offer_issuer_id and no offer_path",
583588
"valid": false,

0 commit comments

Comments
 (0)