41 lines
995 B
Swift
41 lines
995 B
Swift
|
//
|
||
|
// 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
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|