Skip to content

Commit

Permalink
Successfully send to 2 outputs
Browse files Browse the repository at this point in the history
Sent 2 outputs with 1 input

Need to readd refactor
remove cruft
refactored constant
fixed dupe constant
Further polish for confirmation for sending
  • Loading branch information
kcw-grunt committed Dec 3, 2023
1 parent 170068a commit ea32dc6
Show file tree
Hide file tree
Showing 9 changed files with 684 additions and 174 deletions.
23 changes: 1 addition & 22 deletions litewallet/src/Constants/ArticleIds.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
import Foundation

enum ArticleIds {
static let displayCurrency = "display-currency"
static let recoverWallet = "recover-wallet"
static let reScan = "re-scan"
static let securityCenter = "security-center"
static let buyCenter = "buy-center"
static let paperKey = "paper-key"
static let enableTouchId = "enable-fingerprint-authentication"
static let touchIdSpendingLimit = "fingerprint-spending-limit"
static let transactionDetails = "transaction-details"
static let manageWallet = "manage-wallet"
static let receiveBitcoin = "receive-bitcoin"
static let requestAmount = "request-amount"
static let sendBitcoin = "send-bitcoin"
static let walletDisabled = "wallet-disabled"
static let resetPinWithPaperKey = "reset-pin-paper-key"
static let setPin = "set-pin"
static let importWallet = "import-wallet"
static let writePhrase = "write-phrase"
static let confirmPhrase = "confirm-phrase"
static let startView = "start-view"
static let wipeWallet = "wipe-wallet"
static let wipeEmptyWallet = "wipe-empty-wallet"
static let nothing = "nothing"
}
1 change: 1 addition & 0 deletions litewallet/src/Constants/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import UIKit
let π: CGFloat = .pi
let customUserAgent: String = "litewallet-ios"
let litecoinCardURL: String = "https://litecoin.dashboard.getblockcard.com/"
let swiftUICellPadding = 12.0

/// Sets tthe wallet type, the image and the label
enum WalletType: String {
Expand Down
6 changes: 3 additions & 3 deletions litewallet/src/Constants/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ enum S {
static let cameraUnavailableTitle = Localization(key: "Send.cameraUnavailableTitle", value: "**Litewallet is not allowed to access the camera**", comment: "Camera not allowed alert title")
static let cameraUnavailableMessage = Localization(key: "Send.cameraunavailableMessage", value: "**Go to Settings to allow camera access.**", comment: "Camera not allowed message")
static let balance = Localization(key: "Send.balance", value: "**Balance: %1$@**", comment: "Balance: $4.00")
static let fee = Localization(key: "Send.fees", value: "**Fees: %1$@**", comment: "Fees: $0.10")
static let feeBlank = Localization(key: "Send.feeBlank", value: "**Fees:**", comment: "Fees: ")
static let bareFee = Localization(key: "Send.fee", value: "**Fee: %1$@**", comment: "Fee: $0.01")
static let fee = Localization(key: "Send.fees", value: "Fees: %1$@", comment: "Fees: $0.10")
static let feeBlank = Localization(key: "Send.feeBlank", value: "Fees:", comment: "Fees: ")
static let bareFee = Localization(key: "Send.fee", value: "Fee: %1$@", comment: "Fee: $0.01")
static let containsAddress = Localization(key: "Send.containsAddress", value: "**The destination is your own address. You cannot send to yourself.**", comment: "Warning when sending to self.")
enum UsedAddress {
static let title = Localization(key: "Send.UsedAddress.title", value: "**Address Already Used**", comment: "Adress already used alert title")
Expand Down
10 changes: 7 additions & 3 deletions litewallet/src/FeeManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import FirebaseAnalytics
import Foundation

// this is the default that matches the mobile-api if the server is unavailable
private let defaultEconomyFeePerKB: UInt64 = 2500 // From legacy minimum. default min is 1000 as Litecoin Core version v0.17.1
private let defaultEconomyFeePerKB: UInt64 = 8000 // Updated Dec 2, 2024
private let defaultRegularFeePerKB: UInt64 = 25000
private let defaultLuxuryFeePerKB: UInt64 = 66746
private let defaultTimestamp: UInt64 = 1_583_015_199_122
Expand Down Expand Up @@ -49,7 +49,8 @@ class FeeUpdater: Trackable {
walletManager.apiClient?.feePerKb { newFees, error in
guard error == nil
else {
let properties: [String: String] = ["ERROR_MESSAGE": String(describing: error), "ERROR_TYPE": "FEE_PER_KB"]
let properties: [String: String] = ["ERROR_MESSAGE": String(describing: error),
"ERROR_TYPE": "FEE_PER_KB"]
LWAnalytics.logEventWithParameters(itemName: ._20200112_ERR, properties: properties)
completion()
return
Expand All @@ -65,7 +66,10 @@ class FeeUpdater: Trackable {
}

if timer == nil {
timer = Timer.scheduledTimer(timeInterval: feeUpdateInterval, target: self, selector: #selector(intervalRefresh), userInfo: nil, repeats: true)
timer = Timer.scheduledTimer(timeInterval: feeUpdateInterval,
target: self,
selector: #selector(intervalRefresh),
userInfo: nil, repeats: true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion litewallet/src/Models/Types.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import UIKit

// MARK: - Satishis
// MARK: - Satoshis

struct Satoshis {
let rawValue: UInt64
Expand Down
17 changes: 0 additions & 17 deletions litewallet/src/Sender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,6 @@ class Sender {
else {
return completion(.creationError(S.Send.createTransactionError.localize()))
}
//
// if !hasActivatedInlineFees {}
// else {
// let opsFee = tieredOpsFee(amount: transaction?.outputs.)
//
// createTransaction(amount: opsFee, to: Partner.partnerKeyPath(name: .litewalletOps))
// }
////
// // }
//
// print(tx.outputs)
//
//// let fee = tx.addOutput(amount: <#T##UInt64#>, script: T##[UInt8])
////
//// (amount: <#T##UInt64#>, script: <#T##[UInt8]#>)
////
//// addOutput

self.rate = rate
self.comment = comment
Expand Down
60 changes: 30 additions & 30 deletions litewallet/src/ViewControllers/AmountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@ import UIKit
private let currencyToggleConstant: CGFloat = 20.0
private let amountFont: UIFont = UIFont.barlowMedium(size: 14.0)
class AmountViewController: UIViewController, Trackable {
private let store: Store
private let isPinPadExpandedAtLaunch: Bool
private let isRequesting: Bool
var minimumFractionDigits = 2
private var hasTrailingDecimal = false
private var pinPadHeight: NSLayoutConstraint?
private var feeSelectorHeight: NSLayoutConstraint?
private var feeSelectorTop: NSLayoutConstraint?
private var placeholder = PaddingLabel(font: amountFont, color: .grayTextTint)
private var amountLabel = UILabel(font: amountFont, color: .darkText)
private let pinPad: PinPadViewController
private let currencyToggle: ShadowButton
private let border = UIView(color: .secondaryShadow)
private let bottomBorder = UIView(color: .secondaryShadow)
private let cursor = BlinkingView(blinkColor: C.defaultTintColor)
private let balanceLabel = UILabel()
private let feeLabel = UILabel()
private let feeContainer = InViewAlert(type: .secondary)
private let tapView = UIView()
private let editFee = UIButton(type: .system)
private let feeSelector: FeeSelector

private var amount: Satoshis? {
didSet {
updateAmountLabel()
updateBalanceLabel()
didUpdateAmount?(amount)
}
}

init(store: Store,
isPinPadExpandedAtLaunch: Bool,
hasAcceptedFees _: Bool,
Expand Down Expand Up @@ -53,36 +83,6 @@ class AmountViewController: UIViewController, Trackable {
}
}

private let store: Store
private let isPinPadExpandedAtLaunch: Bool
private let isRequesting: Bool
var minimumFractionDigits = 2
private var hasTrailingDecimal = false
private var pinPadHeight: NSLayoutConstraint?
private var feeSelectorHeight: NSLayoutConstraint?
private var feeSelectorTop: NSLayoutConstraint?
private var placeholder = PaddingLabel(font: amountFont, color: .grayTextTint)
private var amountLabel = UILabel(font: amountFont, color: .darkText)
private let pinPad: PinPadViewController
private let currencyToggle: ShadowButton
private let border = UIView(color: .secondaryShadow)
private let bottomBorder = UIView(color: .secondaryShadow)
private let cursor = BlinkingView(blinkColor: C.defaultTintColor)
private let balanceLabel = UILabel()
private let feeLabel = UILabel()
private let feeContainer = InViewAlert(type: .secondary)
private let tapView = UIView()
private let editFee = UIButton(type: .system)
private let feeSelector: FeeSelector

private var amount: Satoshis? {
didSet {
updateAmountLabel()
updateBalanceLabel()
didUpdateAmount?(amount)
}
}

override func viewDidLoad() {
if #available(iOS 11.0, *) {
guard let headerTextColor = UIColor(named: "headerTextColor"),
Expand Down
13 changes: 8 additions & 5 deletions litewallet/src/ViewControllers/ConfirmationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import UIKit

class ConfirmationViewController: UIViewController, ContentBoxPresenter {
init(amount: Satoshis,
fee: Satoshis,
txFee: Satoshis,
opsFee: Satoshis,
feeType: FeeType,
state: ReduxState,
selectedRate: Rate?,
minimumFractionDigits: Int?,
address: String, isUsingBiometrics: Bool, isDonation _: Bool = false)
{
self.amount = amount
feeAmount = fee
self.txFee = txFee
self.opsFee = opsFee
self.feeType = feeType
self.state = state
self.selectedRate = selectedRate
Expand All @@ -24,7 +26,8 @@ class ConfirmationViewController: UIViewController, ContentBoxPresenter {
}

private let amount: Satoshis
private let feeAmount: Satoshis
private let txFee: Satoshis
private let opsFee: Satoshis
private let feeType: FeeType
private let state: ReduxState
private let selectedRate: Rate?
Expand Down Expand Up @@ -183,8 +186,8 @@ class ConfirmationViewController: UIViewController, ContentBoxPresenter {
}

let displayAmount = DisplayAmount(amount: amount, state: state, selectedRate: selectedRate, minimumFractionDigits: 2)
let displayFee = DisplayAmount(amount: feeAmount, state: state, selectedRate: selectedRate, minimumFractionDigits: 2)
let displayTotal = DisplayAmount(amount: amount + feeAmount, state: state, selectedRate: selectedRate, minimumFractionDigits: 2)
let displayFee = DisplayAmount(amount: txFee + opsFee, state: state, selectedRate: selectedRate, minimumFractionDigits: 2)
let displayTotal = DisplayAmount(amount: amount + txFee + opsFee, state: state, selectedRate: selectedRate, minimumFractionDigits: 2)

toLabel.text = S.Confirmation.to.localize()
feeLabel.text = S.Send.feeBlank.localize()
Expand Down
Loading

0 comments on commit ea32dc6

Please sign in to comment.