-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
482 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
LDKNodeMonday/View Model/Home/Receive/Bolt12ZeroInvoiceViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Bolt12ZeroInvoiceViewModel.swift | ||
// LDKNodeMonday | ||
// | ||
// Created by Matthew Ramsden on 6/19/24. | ||
// | ||
|
||
import Foundation | ||
import LDKNode | ||
import SwiftUI | ||
|
||
class Bolt12ZeroInvoiceViewModel: ObservableObject { | ||
@Published var invoice: Bolt12Invoice = "" | ||
@Published var receiveViewError: MondayError? | ||
@Published var networkColor = Color.gray | ||
|
||
func receivePayment(description: String) async { | ||
do { | ||
let invoice = try await LightningNodeService.shared.receiveVariableAmountBolt12( | ||
description: description | ||
) | ||
DispatchQueue.main.async { | ||
self.invoice = invoice | ||
} | ||
} catch let error as NodeError { | ||
let errorString = handleNodeError(error) | ||
DispatchQueue.main.async { | ||
self.receiveViewError = .init(title: errorString.title, detail: errorString.detail) | ||
} | ||
} catch { | ||
DispatchQueue.main.async { | ||
self.receiveViewError = .init( | ||
title: "Unexpected error", | ||
detail: error.localizedDescription | ||
) | ||
} | ||
} | ||
} | ||
|
||
func getColor() { | ||
let color = LightningNodeService.shared.networkColor | ||
DispatchQueue.main.async { | ||
self.networkColor = color | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.