lnd-demo-app/wallet/ViewModels/PaymentsViewModel.swift

41 lines
995 B
Swift
Raw Normal View History

2023-06-08 06:36:06 +00:00
//
// PaymentsViewModel.swift
// wallet
//
// Created by Adriana Epure on 22.08.2022.
// Copyright © 2022 Jason. All rights reserved.
//
class PaymentsViewModel: ViewModel {
let paymentInfo = Observable<Lnrpc_PayReq?>()
func updateBalance(){
self.getWalletBalance()
self.getChannelBalance()
}
func getPaymentDetail(invoice: String){
self.getPaymentInfo(invoice: invoice) { payment in
self.paymentInfo.value = payment
} onFailure: { error in
self.paymentInfo.value = nil
}
}
func sendPayment(invoice: String, completion: @escaping (String) -> Void) {
self.payInvoice(invoice: invoice) { response in
self.listPayments()
self.updateBalance()
debugPrint(response.paymentRoute.totalAmt, response.paymentRoute.totalFees, response.paymentError.debugDescription)
} onFailure: { error in
}
}
}