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
6 changes: 6 additions & 0 deletions DashWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@
751C05DB2D3D0E8C00475E52 /* JoinDashPayViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 751C05DA2D3D0E7C00475E52 /* JoinDashPayViewModel.swift */; };
751C05DD2D3E39A800475E52 /* TransactionListDataItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 751C05DC2D3E39A600475E52 /* TransactionListDataItem.swift */; };
751C05DE2D3E39A800475E52 /* TransactionListDataItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 751C05DC2D3E39A600475E52 /* TransactionListDataItem.swift */; };
5A1EC0FE2E29A30000000002 /* CoinJoinMoveFundsSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1EC0FE2E29A30000000001 /* CoinJoinMoveFundsSheet.swift */; };
5A1EC0FE2E29A30000000003 /* CoinJoinMoveFundsSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1EC0FE2E29A30000000001 /* CoinJoinMoveFundsSheet.swift */; };
7527720D2AA9B2630066557E /* SupportedTopperAssets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7527720C2AA9B2630066557E /* SupportedTopperAssets.swift */; };
7527720F2AA9F58E0066557E /* TopperViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7527720E2AA9F58E0066557E /* TopperViewModel.swift */; };
752772122AAA1CE30066557E /* Coinbase-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 752772112AAA1CE30066557E /* Coinbase-Info.plist */; };
Expand Down Expand Up @@ -2840,6 +2842,7 @@
751C05D82D3BB6A200475E52 /* CurrentUserProfileModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurrentUserProfileModel.swift; sourceTree = "<group>"; };
751C05DA2D3D0E7C00475E52 /* JoinDashPayViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JoinDashPayViewModel.swift; sourceTree = "<group>"; };
751C05DC2D3E39A600475E52 /* TransactionListDataItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionListDataItem.swift; sourceTree = "<group>"; };
5A1EC0FE2E29A30000000001 /* CoinJoinMoveFundsSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoinJoinMoveFundsSheet.swift; sourceTree = "<group>"; };
7527720C2AA9B2630066557E /* SupportedTopperAssets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportedTopperAssets.swift; sourceTree = "<group>"; };
7527720E2AA9F58E0066557E /* TopperViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopperViewModel.swift; sourceTree = "<group>"; };
752772112AAA1CE30066557E /* Coinbase-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Coinbase-Info.plist"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4331,6 +4334,7 @@
754BEA112C0B6BD700E8C93C /* HomeViewModel.swift */,
751C05DC2D3E39A600475E52 /* TransactionListDataItem.swift */,
5A1EC0FE2E29A10000000001 /* ShieldedActivityHistory.swift */,
5A1EC0FE2E29A30000000001 /* CoinJoinMoveFundsSheet.swift */,
5A1EC0FE2E29A20000000014 /* PlatformAddressHistory.swift */,
75D657662DF579F300ACE570 /* TransactionFilterDialog.swift */,
4E55DD28C4EBE049216291A2 /* HomeUsernameRow.swift */,
Expand Down Expand Up @@ -9626,6 +9630,7 @@
470AE1882926600A001A0514 /* PaymentController.swift in Sources */,
751C05DE2D3E39A800475E52 /* TransactionListDataItem.swift in Sources */,
5A1EC0FE2E29A10000000003 /* ShieldedActivityHistory.swift in Sources */,
5A1EC0FE2E29A30000000003 /* CoinJoinMoveFundsSheet.swift in Sources */,
5A1EC0FE2E29A20000000013 /* PlatformAddressActivityStore.swift in Sources */,
5A1EC0FE2E29A20000000016 /* PlatformAddressHistory.swift in Sources */,
2ADB396C242615C200A6F898 /* CALayer+MBAnimationPersistence.m in Sources */,
Expand Down Expand Up @@ -10440,6 +10445,7 @@
C9D2C95E2A386D7E00D15901 /* DWBasePressableControl.m in Sources */,
751C05DD2D3E39A800475E52 /* TransactionListDataItem.swift in Sources */,
5A1EC0FE2E29A10000000002 /* ShieldedActivityHistory.swift in Sources */,
5A1EC0FE2E29A30000000002 /* CoinJoinMoveFundsSheet.swift in Sources */,
5A1EC0FE2E29A20000000012 /* PlatformAddressActivityStore.swift in Sources */,
5A1EC0FE2E29A20000000015 /* PlatformAddressHistory.swift in Sources */,
C9D2C70B2A320AA000D15901 /* DWDemoAppRootViewController.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ final class SwiftDashSDKTransactionSender: NSObject {
vaultAddress: String,
amountDuffs: UInt64,
memo: String
) throws -> (tx: CoreTransaction, txHash: Data) {
) throws -> (tx: FinalizedCoreTransaction, txHash: Data) {
let memoData = Data(memo.utf8)
guard memoData.count <= Self.maxSwapMemoBytes else {
throw SendError.invalidSwapMemo("Swap memo is too long. Please refresh and try again.")
}

logger.info("💸 TXSEND :: building+signing MAYA swap deposit via PlatformWalletManager.coreWallet")

let build = { @MainActor () throws -> (tx: CoreTransaction, network: Network) in
let build = { @MainActor () throws -> (tx: FinalizedCoreTransaction, network: Network) in
guard let wallet = SwiftDashSDKHost.shared.wallet,
let network = SwiftDashSDKHost.shared.runningNetwork else {
throw SendError.walletNotReady("PlatformWalletManager wallet is not available")
Expand All @@ -153,33 +153,34 @@ final class SwiftDashSDKTransactionSender: NSObject {
try builder.addOpReturn(memoData)
try builder.preserveOutputOrder()
try builder.changeToFirstInput()
try builder.setFunding(wallet: wallet, accountType: .bip44, accountIndex: 0)
let tx = try builder.buildSigned(wallet: wallet, accountType: .bip44, accountIndex: 0)
let tx = try builder.finalizeAtomic(wallet: wallet, accountType: .bip44, accountIndex: 0)
return (tx, network)
}

let built: (tx: CoreTransaction, network: Network)
let built: (tx: FinalizedCoreTransaction, network: Network)
if Thread.isMainThread {
built = try MainActor.assumeIsolated { try build() }
} else {
var captured: Result<(tx: CoreTransaction, network: Network), Error> =
var captured: Result<(tx: FinalizedCoreTransaction, network: Network), Error> =
.failure(SendError.walletNotReady("uninitialized result"))
DispatchQueue.main.sync {
captured = Result { try MainActor.assumeIsolated { try build() } }
}
built = try captured.get()
}

let txData = try built.tx.serializedData()
try assertSwapDepositShape(
tx: built.tx,
txData: txData,
feeDuffs: built.tx.fee,
network: built.network,
vaultAddress: vaultAddress,
amountDuffs: amountDuffs,
memoData: memoData
)

let txHash = computeTxHash(from: built.tx.data)
logger.info("💸 TXSEND :: built+signed MAYA swap deposit — txHash=\(txHash.map { String(format: "%02x", $0) }.joined(), privacy: .public) fee=\(built.tx.fee, privacy: .public) duffs size=\(built.tx.data.count, privacy: .public) bytes")
let txHash = computeTxHash(from: txData)
logger.info("💸 TXSEND :: built+signed MAYA swap deposit — txHash=\(txHash.map { String(format: "%02x", $0) }.joined(), privacy: .public) fee=\(built.tx.fee, privacy: .public) duffs size=\(txData.count, privacy: .public) bytes")
return (built.tx, txHash)
}

Expand Down Expand Up @@ -591,13 +592,14 @@ final class SwiftDashSDKTransactionSender: NSObject {
}

private static func assertSwapDepositShape(
tx: CoreTransaction,
txData: Data,
feeDuffs: UInt64,
network: Network,
vaultAddress: String,
amountDuffs: UInt64,
memoData: Data
) throws {
let decoded = try TransactionDecoder.decode(tx.data, network: network)
let decoded = try TransactionDecoder.decode(txData, network: network)
guard decoded.outputs.count >= 2, decoded.outputs.count <= 3 else {
throw SendError.invalidInput("swap deposit must have 2 or 3 outputs")
}
Expand Down Expand Up @@ -631,7 +633,7 @@ final class SwiftDashSDKTransactionSender: NSObject {
}
}

guard tx.fee >= UInt64(tx.data.count) else {
guard feeDuffs >= UInt64(txData.count) else {
throw SendError.invalidInput("swap deposit fee rate fell below the 1 duff/byte relay minimum")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ final class WalletSendService: NSObject {
)

return PreparedStandardSend(
txData: tx.data,
txData: try tx.serializedData(),
txHash: txHash,
fee: tx.fee,
address: vaultAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ final class OnlineAccountEmailController: UIViewController {
.receive(on: DispatchQueue.main)
.compactMap { $0 }
.sink { [weak self] error in
if let error, error is CrowdNode.Error {
// `compactMap` already unwrapped the published optional.
if error is CrowdNode.Error {
self?.viewModel.clearError()
self?.navigationController?.toErrorScreen(
error: error as? CrowdNode.Error ?? .messageStatus(error: error.localizedDescription))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ extension CrowdNodePortalController {
.receive(on: DispatchQueue.main)
.compactMap { $0 }
.sink(receiveValue: { [weak self] error in
if let error, error is CrowdNode.Error {
// `compactMap` already unwrapped the published optional.
if error is CrowdNode.Error {
self?.viewModel.clearError()
self?.navigationController?.toErrorScreen(
error: error as? CrowdNode.Error ?? .messageStatus(error: error.localizedDescription))
Expand Down
Loading
Loading