BlueWallet/ios/BlueWalletWatch Extension/Objects/Wallet.swift

64 lines
2.1 KiB
Swift
Raw Normal View History

2019-05-02 16:33:03 -04:00
//
// Wallet.swift
// BlueWalletWatch Extension
//
// Created by Marcos Rodriguez on 3/13/19.
2024-01-25 00:39:01 -04:00
2019-05-02 16:33:03 -04:00
//
import Foundation
2020-08-18 22:25:59 -04:00
enum InterfaceMode {
case Address, QRCode
}
2019-05-02 16:33:03 -04:00
class Wallet: NSObject, NSCoding {
static let identifier: String = "Wallet"
var identifier: Int?
let label: String
let balance: String
let type: String
let preferredBalanceUnit: String
let receiveAddress: String
let transactions: [Transaction]
2020-08-16 23:56:05 -04:00
let xpub: String?
let hideBalance: Bool
2019-05-02 16:33:03 -04:00
init(label: String, balance: String, type: String, preferredBalanceUnit: String, receiveAddress: String, transactions: [Transaction], identifier: Int, xpub: String?, hideBalance: Bool = false) {
2019-05-02 16:33:03 -04:00
self.label = label
self.balance = balance
self.type = type
self.preferredBalanceUnit = preferredBalanceUnit
self.receiveAddress = receiveAddress
self.transactions = transactions
self.identifier = identifier
2020-08-16 23:56:05 -04:00
self.xpub = xpub
self.hideBalance = hideBalance
2019-05-02 16:33:03 -04:00
}
func encode(with aCoder: NSCoder) {
aCoder.encode(label, forKey: "label")
aCoder.encode(balance, forKey: "balance")
aCoder.encode(type, forKey: "type")
aCoder.encode(receiveAddress, forKey: "receiveAddress")
aCoder.encode(preferredBalanceUnit, forKey: "preferredBalanceUnit")
aCoder.encode(transactions, forKey: "transactions")
aCoder.encode(identifier, forKey: "identifier")
2020-08-16 23:56:05 -04:00
aCoder.encode(xpub, forKey: "xpub")
aCoder.encode(hideBalance, forKey: "hideBalance")
2019-05-02 16:33:03 -04:00
}
required init?(coder aDecoder: NSCoder) {
label = aDecoder.decodeObject(forKey: "label") as! String
balance = aDecoder.decodeObject(forKey: "balance") as! String
type = aDecoder.decodeObject(forKey: "type") as! String
preferredBalanceUnit = aDecoder.decodeObject(forKey: "preferredBalanceUnit") as! String
receiveAddress = aDecoder.decodeObject(forKey: "receiveAddress") as! String
transactions = aDecoder.decodeObject(forKey: "transactions") as? [Transaction] ?? [Transaction]()
2020-08-16 23:56:05 -04:00
xpub = aDecoder.decodeObject(forKey: "xpub") as? String
hideBalance = aDecoder.decodeObject(forKey: "hideBalance") as? Bool ?? false
2019-05-02 16:33:03 -04:00
}
}