Skip to content

Commit 7e52ac8

Browse files
Fix DASH transaction amount parsing issue
1 parent 4196195 commit 7e52ac8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Adamant/Models/BTCRawTransaction.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ struct BTCOutput: Decodable {
227227
enum CodingKeys: String, CodingKey {
228228
case signature = "scriptPubKey"
229229
case value
230+
case valueSat
230231
case spentTxId
231232
case spentIndex
232233
}
@@ -236,7 +237,7 @@ struct BTCOutput: Decodable {
236237
}
237238

238239
let addresses: [String]
239-
let value: Decimal
240+
var value: Decimal
240241
let spentTxId: String?
241242
let spentIndex: Int?
242243

@@ -254,6 +255,12 @@ struct BTCOutput: Decodable {
254255
self.value = 0
255256
}
256257

258+
if let raw = try? container.decode(String.self, forKey: .valueSat), let value = Decimal(string: raw) {
259+
self.value = Decimal(sign: .plus, exponent: DogeWalletService.currencyExponent, significand: value)
260+
} else if let raw = try? container.decode(Decimal.self, forKey: .valueSat) {
261+
self.value = Decimal(sign: .plus, exponent: DogeWalletService.currencyExponent, significand: raw)
262+
}
263+
257264
self.spentTxId = try? container.decode(String.self, forKey: .spentTxId)
258265
self.spentIndex = try? container.decode(Int.self, forKey: .spentIndex)
259266
}

0 commit comments

Comments
 (0)