Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-8253 Send, Express: (Kaspa) no warning about 84 UTXO #867

Merged
merged 2 commits into from
Oct 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ class KaspaTransactionBuilder {
}

func buildForMassCalculation(transaction: Transaction) throws -> KaspaTransactionData {
let amountValue = min(transaction.amount.value, availableAmount().value)
let amount = Amount(with: blockchain, value: amountValue)

let transaction = transaction.withAmount(amount)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Запустил, проверил, вроде бы все ок.
Запрос фи не фейлится, а после него на валидации возвращается ошибка и показываем кнопку

image


let builtTransaction = try buildForSign(transaction).0
let dummySignature = Data(repeating: 1, count: 65)
return buildForSend(
Expand Down
8 changes: 7 additions & 1 deletion BlockchainSdk/Blockchains/Kaspa/KaspaWalletManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ extension KaspaWalletManager: WithdrawalNotificationProvider {

extension KaspaWalletManager: MaximumAmountRestrictable {
func validateMaximumAmount(amount: Amount, fee: Amount) throws {
let amountAvailableToSend = txBuilder.availableAmount() - fee
var amountAvailableToSend = txBuilder.availableAmount() - fee

let change = amount - amountAvailableToSend
if change > .zeroCoin(for: wallet.blockchain), change < dustValue {
amountAvailableToSend = amountAvailableToSend - (dustValue - change)
}

if amount <= amountAvailableToSend {
return
}
Expand Down
12 changes: 12 additions & 0 deletions BlockchainSdk/Common/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ public struct Transaction {
self.contractAddress = contractAddress
self.params = params
}

func withAmount(_ amount: Amount) -> Transaction {
Transaction(
amount: amount,
fee: fee,
sourceAddress: sourceAddress,
destinationAddress: destinationAddress,
changeAddress: changeAddress,
contractAddress: contractAddress,
params: params
)
}
}

extension Transaction: Equatable {
Expand Down
Loading