commit d98c6e93d8888035f3add6bec224d7bea9c672d4
parent 4b88a02437b1bfca2274fcbbe0ce76800bdb00fa
Author: William Casarin <jb55@jb55.com>
Date: Thu, 28 Jul 2022 12:05:10 -0700
increase pay timeout
Changelog-Changed: Increase pay timeout to 100 seconds
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lightninglink/RPC.swift b/lightninglink/RPC.swift
@@ -408,13 +408,13 @@ public func rpc_invoice(ln: LNSocket, token: String, amount: InvoiceAmount = .an
return performRpc(ln: ln, operation: "invoice", authToken: token, timeout_ms: default_timeout, params: params)
}
-public func rpc_pay(ln: LNSocket, token: String, bolt11: String, amount_msat: Int64?) -> RequestRes<Pay>
+public func rpc_pay(ln: LNSocket, token: String, bolt11: String, amount_msat: Int64?, timeout_ms: Int32) -> RequestRes<Pay>
{
var params: Array<String> = [ bolt11 ]
if amount_msat != nil {
params.append("\(amount_msat!)msat")
}
- return performRpc(ln: ln, operation: "pay", authToken: token, timeout_ms: 30000, params: params)
+ return performRpc(ln: ln, operation: "pay", authToken: token, timeout_ms: timeout_ms, params: params)
}
public func rpc_listfunds(ln: LNSocket, token: String) -> RequestRes<ListFunds>
diff --git a/lightninglink/Views/PayView.swift b/lightninglink/Views/PayView.swift
@@ -87,6 +87,7 @@ struct PayView: View {
let rate: ExchangeRate?
let expiry_timer = Timer.publish(every: 1, on: .main, in: .default).autoconnect()
+ let pay_timeout_ms: Int32 = 100_000
@State var pay_result: Pay?
@State var state: PayState = .initial
@@ -370,8 +371,8 @@ struct PayView: View {
}
}
- func confirm_pay(ln: LNSocket?, inv: String, pay_amt: PayAmount?) {
- let res = confirm_payment(ln: ln, lnlink: self.lnlink, bolt11: inv, pay_amt: pay_amt)
+ func confirm_pay(ln: LNSocket?, inv: String, pay_amt: PayAmount?, timeout_ms: Int32) {
+ let res = confirm_payment(ln: ln, lnlink: self.lnlink, bolt11: inv, pay_amt: pay_amt, timeout_ms: timeout_ms)
switch res {
case .left(let err):
self.paying = false
@@ -418,7 +419,7 @@ struct PayView: View {
}
DispatchQueue.global(qos: .background).async {
- confirm_pay(ln: mln, inv: invstr, pay_amt: nil)
+ confirm_pay(ln: mln, inv: invstr, pay_amt: nil, timeout_ms: pay_timeout_ms)
}
case .offer:
self.error = "Got an offer from a lnurl pay request? What?"
@@ -462,7 +463,7 @@ struct PayView: View {
self.paying = false
self.error = err.description
case .success(let fetch_invoice):
- confirm_pay(ln: ln, inv: fetch_invoice.invoice, pay_amt: nil)
+ confirm_pay(ln: ln, inv: fetch_invoice.invoice, pay_amt: nil, timeout_ms: pay_timeout_ms)
}
}
}
@@ -485,7 +486,7 @@ struct PayView: View {
let pay_amt = get_pay_amount(invoice.amount)
self.paying = true
DispatchQueue.global(qos: .background).async {
- confirm_pay(ln: mln, inv: invoice.invstr, pay_amt: pay_amt)
+ confirm_pay(ln: mln, inv: invoice.invstr, pay_amt: pay_amt, timeout_ms: pay_timeout_ms)
}
case .initial: fallthrough
@@ -682,7 +683,7 @@ public enum Either<L, R> {
}
}
-func confirm_payment(ln mln: LNSocket?, lnlink: LNLink, bolt11: String, pay_amt: PayAmount?) -> Either<String, Pay> {
+func confirm_payment(ln mln: LNSocket?, lnlink: LNLink, bolt11: String, pay_amt: PayAmount?, timeout_ms: Int32) -> Either<String, Pay> {
let ln = mln ?? LNSocket()
if mln == nil {
@@ -700,7 +701,9 @@ func confirm_payment(ln mln: LNSocket?, lnlink: LNLink, bolt11: String, pay_amt:
ln: ln,
token: lnlink.token,
bolt11: bolt11,
- amount_msat: amount_msat)
+ amount_msat: amount_msat,
+ timeout_ms: timeout_ms
+ )
switch res {
case .failure(let req_err):