commit 1d8dd226e87bbe3fa0ad76580c1015355f854c5a parent fb2575e62a436cfcbb5e37b705614f898307d4e7 Author: William Casarin <jb55@jb55.com> Date: Sun, 6 Mar 2022 12:00:41 -0800 expiry is called relative_expiry for bolt12s Signed-off-by: William Casarin <jb55@jb55.com> Diffstat:
M | lightninglink/RPC.swift | | | 11 | +++++++++++ |
M | lightninglink/Views/PayView.swift | | | 2 | +- |
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lightninglink/RPC.swift b/lightninglink/RPC.swift @@ -52,6 +52,7 @@ public struct Decode: Decodable { public var valid: Bool public var created_at: Int64? public var expiry: Int64? + public var relative_expiry: Int64? public var payee: String? public var msatoshi: Int64? public var quantity_min: Int? @@ -61,6 +62,16 @@ public struct Decode: Decodable { public var vendor: String? } +func get_decode_expiry(_ decode: Decode) -> Int64? { + // bolt11 + if decode.expiry != nil { + return decode.expiry + } + + // bolt12 + return decode.relative_expiry +} + public struct FetchInvoice: Decodable { public var invoice: String } diff --git a/lightninglink/Views/PayView.swift b/lightninglink/Views/PayView.swift @@ -461,7 +461,7 @@ struct PayView: View { return } - guard let expiry = invoice.expiry else { + guard let expiry = get_decode_expiry(invoice) else { self.expiry_percent = nil return }