Skip to content

Commit

Permalink
Set incoming transaction confirmation threshold to 1 for BTC, BCH, LT…
Browse files Browse the repository at this point in the history
…C and DASH
  • Loading branch information
esen committed Dec 13, 2024
1 parent 81f3b58 commit d7765f5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BitcoinAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .hdExtendedKey(key):
Expand All @@ -41,7 +41,7 @@ class BitcoinAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .btcAddress(address, _, tokenType):
Expand All @@ -55,7 +55,7 @@ class BitcoinAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import MarketKit
import RxSwift

class BitcoinBaseAdapter {
static let confirmationsThreshold = 3
static let confirmationsThreshold = 1 // Number of confirmations for coins in transaction to be available for spending
static let txStatusConfirmationsThreshold = 3 // Number of confirmations for transaction status displayed
private let abstractKit: AbstractKit

var coinRate: Decimal { 100_000_000 } // pow(10, 8)
Expand Down Expand Up @@ -86,7 +87,7 @@ class BitcoinBaseAdapter {
transactionHash: transaction.transactionHash,
transactionIndex: transaction.transactionIndex,
blockHeight: transaction.blockHeight,
confirmationsThreshold: Self.confirmationsThreshold,
confirmationsThreshold: Self.txStatusConfirmationsThreshold,
date: Date(timeIntervalSince1970: Double(transaction.timestamp)),
fee: transaction.fee.map { Decimal($0) / coinRate },
failed: transaction.status == .invalid,
Expand All @@ -105,7 +106,7 @@ class BitcoinBaseAdapter {
transactionHash: transaction.transactionHash,
transactionIndex: transaction.transactionIndex,
blockHeight: transaction.blockHeight,
confirmationsThreshold: Self.confirmationsThreshold,
confirmationsThreshold: Self.txStatusConfirmationsThreshold,
date: Date(timeIntervalSince1970: Double(transaction.timestamp)),
fee: transaction.fee.map { Decimal($0) / coinRate },
failed: transaction.status == .invalid,
Expand All @@ -126,7 +127,7 @@ class BitcoinBaseAdapter {
transactionHash: transaction.transactionHash,
transactionIndex: transaction.transactionIndex,
blockHeight: transaction.blockHeight,
confirmationsThreshold: Self.confirmationsThreshold,
confirmationsThreshold: Self.txStatusConfirmationsThreshold,
date: Date(timeIntervalSince1970: Double(transaction.timestamp)),
fee: transaction.fee.map { Decimal($0) / coinRate },
failed: transaction.status == .invalid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BitcoinCashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .hdExtendedKey(key):
Expand All @@ -41,7 +41,7 @@ class BitcoinCashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .btcAddress(address, _, _):
Expand All @@ -50,7 +50,7 @@ class BitcoinCashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: nil
)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .hdExtendedKey(key):
Expand All @@ -35,7 +35,7 @@ class DashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .btcAddress(address, _, _):
Expand All @@ -44,7 +44,7 @@ class DashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import RxSwift

class ECashAdapter: BitcoinBaseAdapter {
private static let networkType: ECashKit.Kit.NetworkType = .mainNet
private static let eCashConfirmationsThreshold = 1
override var coinRate: Decimal { 100 } // pow(10,2)

private let eCashKit: ECashKit.Kit
Expand All @@ -26,7 +25,7 @@ class ECashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: Self.eCashConfirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .hdExtendedKey(key):
Expand All @@ -35,7 +34,7 @@ class ECashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: Self.eCashConfirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .btcAddress(address, _, _):
Expand All @@ -44,7 +43,7 @@ class ECashAdapter: BitcoinBaseAdapter {
walletId: wallet.account.id,
syncMode: syncMode,
networkType: Self.networkType,
confirmationsThreshold: Self.eCashConfirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LitecoinAdapter: BitcoinBaseAdapter {
syncMode: syncMode,
hasher: hasher,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .hdExtendedKey(key):
Expand All @@ -58,7 +58,7 @@ class LitecoinAdapter: BitcoinBaseAdapter {
syncMode: syncMode,
hasher: hasher,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
case let .btcAddress(address, _, tokenType):
Expand All @@ -73,7 +73,7 @@ class LitecoinAdapter: BitcoinBaseAdapter {
syncMode: syncMode,
hasher: hasher,
networkType: Self.networkType,
confirmationsThreshold: BitcoinBaseAdapter.confirmationsThreshold,
confirmationsThreshold: Self.confirmationsThreshold,
logger: logger
)
default:
Expand Down

0 comments on commit d7765f5

Please sign in to comment.