Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions DashWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DashWallet/Sources/Application/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ final class App {
static let shared = App()

func cleanUp() {
TxUserInfoDAOImpl.shared.deleteAll()
TransactionMetadataDAOImpl.shared.deleteAll()
AddressUserInfoDAOImpl.shared.deleteAll()
#if DASHPAY
UsernameRequestsDAOImpl.shared.deleteAll()
Expand Down
17 changes: 17 additions & 0 deletions DashWallet/Sources/Categories/Foundation+Bitcoin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ extension Data {
let rawValue: Int
static let upperCase = HexEncodingOptions(rawValue: 1 << 0)
}

init?(hex: String) {
let len = hex.count / 2
var data = Data(capacity: len)
var i = hex.startIndex
for _ in 0..<len {
let j = hex.index(i, offsetBy: 2)
let bytes = hex[i..<j]
if var num = UInt8(bytes, radix: 16) {
data.append(&num, count: 1)
} else {
return nil
}
i = j
}
self = data
}

func hexEncodedString(options: HexEncodingOptions = []) -> String {
let format = options.contains(.upperCase) ? "%02hhX" : "%02hhx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension DatabaseConnection {
}

static func migrations() -> [Migration] {
[SeedDB(), AddGiftCardsTable()]
[SeedDB(), AddGiftCardsTable(), AddIconBitmapsTable()]
}

static func migrationsBundle() -> Bundle {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Adding metadata fields to tx_userinfo table
ALTER TABLE tx_userinfo ADD timestamp BIGINT NULL;
ALTER TABLE tx_userinfo ADD memo TEXT NULL;
ALTER TABLE tx_userinfo ADD service TEXT NULL;
ALTER TABLE tx_userinfo ADD customIconId BLOB NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Created by Andrei Ashikhmin
// Copyright © 2025 Dash Core Group. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import SQLite
import SQLiteMigrationManager

struct AddIconBitmapsTable: Migration {
var version: Int64 = 20250114130000

func migrateDatabase(_ db: Connection) throws {
try db.run(IconBitmap.table.create(ifNotExists: true) { t in
t.column(IconBitmap.id, primaryKey: true)
t.column(IconBitmap.imageData)
t.column(IconBitmap.originalUrl)
t.column(IconBitmap.height)
t.column(IconBitmap.width)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SQLite
import SQLiteMigrationManager

struct SeedDB: Migration {
var version: Int64 = 20241130210940
var version: Int64 = 20250418145536

func migrateDatabase(_ db: Connection) throws { }
}
6 changes: 3 additions & 3 deletions DashWallet/Sources/Models/Taxes/Address/AddressUserInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import SQLite

@objc class AddressUserInfo: NSObject {
@objc var address: String
@objc var taxCategory: TxUserInfoTaxCategory = .unknown
@objc var taxCategory: TxMetadataTaxCategory = .unknown

@objc
init(address: String, taxCategory: TxUserInfoTaxCategory) {
init(address: String, taxCategory: TxMetadataTaxCategory) {
self.address = address
self.taxCategory = taxCategory
}

init(row: Row) {
address = row[AddressUserInfo.addressColumn]
taxCategory = TxUserInfoTaxCategory(rawValue: row[TxUserInfo.txCategoryColumn]) ?? .unknown
taxCategory = TxMetadataTaxCategory(rawValue: row[TransactionMetadata.txCategoryColumn]) ?? .unknown

super.init()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ enum TaxReportGenerator {

DispatchQueue.global(qos: .default).async {
let transactions = transactions
let userInfosArray = TxUserInfoDAOImpl().all()
let userInfos = userInfosArray.reduce(into: [Data: TxUserInfo]()) { partialResult, dto in
let userInfosArray = TransactionMetadataDAOImpl().all()
let userInfos = userInfosArray.reduce(into: [Data: TransactionMetadata]()) { partialResult, dto in
partialResult[dto.txHash] = dto
}

Expand Down Expand Up @@ -119,7 +119,7 @@ enum TaxReportGenerator {
return fileName
}

private static func value(for column: ReportColumns, transaction: DSTransaction, andUserInfo userInfo: TxUserInfo?) -> String {
private static func value(for column: ReportColumns, transaction: DSTransaction, andUserInfo userInfo: TransactionMetadata?) -> String {
let transactionDirection = transaction.direction
let isOutcoming = transactionDirection == .sent

Expand Down
14 changes: 7 additions & 7 deletions DashWallet/Sources/Models/Taxes/Taxes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Foundation
// MARK: - TxUserInfoTaxCategory

@objc
enum TxUserInfoTaxCategory: Int {
enum TxMetadataTaxCategory: Int {
/// Unknown
case unknown

Expand Down Expand Up @@ -51,15 +51,15 @@ enum TxUserInfoTaxCategory: Int {
class Taxes: NSObject {

var addressesUserInfos: AddressUserInfoDAO = AddressUserInfoDAOImpl()
var txUserInfos: TxUserInfoDAO = TxUserInfoDAOImpl.shared
var txUserInfos: TransactionMetadataDAO = TransactionMetadataDAOImpl.shared

@objc
func mark(address: String, with taxCategory: TxUserInfoTaxCategory) {
func mark(address: String, with taxCategory: TxMetadataTaxCategory) {
addressesUserInfos.create(dto: AddressUserInfo(address: address, taxCategory: taxCategory))
}

func taxCategory(for tx: DSTransaction) -> TxUserInfoTaxCategory {
var taxCategory: TxUserInfoTaxCategory = tx.defaultTaxCategory()
func taxCategory(for tx: DSTransaction) -> TxMetadataTaxCategory {
var taxCategory: TxMetadataTaxCategory = tx.defaultTaxCategory()

for outputAddress in tx.outputAddresses {
if let address = outputAddress as? String, let txCategory = self.taxCategory(for: address) {
Expand All @@ -80,11 +80,11 @@ class Taxes: NSObject {
return taxCategory
}

func taxCategory(for tx: Transaction) -> TxUserInfoTaxCategory {
func taxCategory(for tx: Transaction) -> TxMetadataTaxCategory {
taxCategory(for: tx.tx)
}

func taxCategory(for address: String) -> TxUserInfoTaxCategory? {
func taxCategory(for address: String) -> TxMetadataTaxCategory? {
addressesUserInfos.get(by: address)?.taxCategory
}

Expand Down
136 changes: 0 additions & 136 deletions DashWallet/Sources/Models/Taxes/Tx/DAO/TxUserInfoDAO.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Transaction: TransactionDataItem, Identifiable {

private lazy var storedFiatAmount = userInfo?.fiatAmountString(from: _dashAmount) ?? NSLocalizedString("Not available", comment: "");

lazy var userInfo: TxUserInfo? = TxUserInfoDAOImpl.shared.get(by: tx.txHashData)
lazy var userInfo: TransactionMetadata? = TransactionMetadataDAOImpl.shared.get(by: tx.txHashData)

var transactionType: `Type` { _transactionType }
private lazy var _transactionType: `Type` = tx.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extension SendCoinsService: DWPaymentProcessorDelegate {
}

public func paymentProcessor(_ processor: DWPaymentProcessor, requestAmountWithDestination sendingDestination: String, details: DSPaymentProtocolDetails?, contactItem: DWDPBasicUserItem?) {
completePayment(transaction: nil, error: CTXSpendError.paymentProcessingError("Amount request not supported"))
completePayment(transaction: nil, error: CTXSpendError.paymentProcessingError("Request is missing destination"))
}

public func paymentProcessor(_ processor: DWPaymentProcessor, requestUserActionTitle title: String?, message: String?, actionTitle: String, cancel cancelBlock: (() -> Void)?, actionBlock: (() -> Void)?) {
Expand Down
Loading