-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* move the git submodule to the latest - v1.0.0 releease of loafwallet-core # Conflicts: # Modules/loafwallet-core * ISSUE: Not able to type and display recv addresses - There is a failiure in the conversion from CChar to Int8 - Have send working - updated loafwallet-core v1.1.0 - Added falsePositived interface - Added enum and set values for - low privacy - semi-private - anonymous - Updated the loafwallet-core - adds the fpRate var * Resolved PeerManager set with proper optional setting. * WIP: Cannot unwrap ltc1 addresses to retain them in the UILabel - ltc1 addresses are present but not unwrapping properly @Iferencak this is the disappearing error you saw when we updated the loafwallet-core. - Not able to figure this out yet. - All ideas are welcome * WIP: Still debugging - The issue is the BRCore methods compare the `ltc1` address against the set of addresses and it fails because the BRSet is not setup for the address. The issue is this worked before and I need to investigate what happened before and how things changed Signed-off-by: kcw-grunt <[email protected]> * move the git submodule to the latest - v1.0.0 releease of loafwallet-core * Bugfix!: Duplicated char in converter Added optic enum Signed-off-by: kcw-grunt <[email protected]> * Move all the extensions from BRCore to separate files - Moved these into separate files to help debug Signed-off-by: kcw-grunt <[email protected]> * Refactored the conversion - Fixed a bug where a element is duplicated `unichar(charArray.20),unichar(charArray.21), unichar(charArray.22), unichar(charArray.23), unichar(charArray.23), unichar(charArray.24)` Signed-off-by: kcw-grunt <[email protected]> --------- Signed-off-by: kcw-grunt <[email protected]>
- Loading branch information
Showing
19 changed files
with
895 additions
and
725 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// BRAddressExtension.swift | ||
// loafwallet | ||
// | ||
// Created by Kerry Washington on 11/4/23. | ||
// Copyright © 2023 Litecoin Foundation. All rights reserved. | ||
// | ||
import BRCore | ||
import Foundation | ||
|
||
extension BRAddress: CustomStringConvertible, Hashable { | ||
init?(string: String) { | ||
self.init() | ||
let cStr = [CChar](string.utf8CString) | ||
guard cStr.count <= MemoryLayout<BRAddress>.size else { return nil } | ||
UnsafeMutableRawPointer(mutating: &s).assumingMemoryBound(to: CChar.self).assign(from: cStr, | ||
count: cStr.count) | ||
} | ||
|
||
init?(scriptPubKey: [UInt8]) { | ||
self.init() | ||
guard BRAddressFromScriptPubKey(UnsafeMutableRawPointer(mutating: &s).assumingMemoryBound(to: CChar.self), | ||
MemoryLayout<BRAddress>.size, scriptPubKey, scriptPubKey.count) > 0 | ||
else { return nil } | ||
} | ||
|
||
init?(scriptSig: [UInt8]) { | ||
self.init() | ||
guard BRAddressFromScriptSig(UnsafeMutableRawPointer(mutating: &s).assumingMemoryBound(to: CChar.self), | ||
MemoryLayout<BRAddress>.size, scriptSig, scriptSig.count) > 0 else { return nil } | ||
} | ||
|
||
var scriptPubKey: [UInt8]? { | ||
var script = [UInt8](repeating: 0, count: 25) | ||
let count = BRAddressScriptPubKey(&script, script.count, | ||
UnsafeRawPointer([s]).assumingMemoryBound(to: CChar.self)) | ||
guard count > 0 else { return nil } | ||
if count < script.count { script.removeSubrange(count...) } | ||
return script | ||
} | ||
|
||
var hash160: UInt160? { | ||
var hash = UInt160() | ||
guard BRAddressHash160(&hash, UnsafeRawPointer([s]).assumingMemoryBound(to: CChar.self)) != 0 | ||
else { return nil } | ||
return hash | ||
} | ||
|
||
public var description: String { | ||
return String(cString: UnsafeRawPointer([s]).assumingMemoryBound(to: CChar.self)) | ||
} | ||
|
||
public var hashValue: Int { | ||
return BRAddressHash([s]) | ||
} | ||
|
||
public static func == (l: BRAddress, r: BRAddress) -> Bool { | ||
return BRAddressEq([l.s], [r.s]) != 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import BRCore | ||
import Foundation | ||
|
||
extension UInt256: CustomStringConvertible { | ||
public var description: String { | ||
return String(format: "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" + | ||
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", | ||
u8.31, u8.30, u8.29, u8.28, u8.27, u8.26, u8.25, u8.24, | ||
u8.23, u8.22, u8.21, u8.20, u8.19, u8.18, u8.17, u8.16, | ||
u8.15, u8.14, u8.13, u8.12, u8.11, u8.10, u8.9, u8.8, | ||
u8.7, u8.6, u8.5, u8.4, u8.3, u8.2, u8.1, u8.0) | ||
} | ||
} | ||
|
||
extension UInt128: Equatable { | ||
public static func == (l: UInt128, r: UInt128) -> Bool { | ||
return l.u64 == r.u64 | ||
} | ||
|
||
public static func != (l: UInt128, r: UInt128) -> Bool { | ||
return l.u64 != r.u64 | ||
} | ||
} | ||
|
||
extension UInt160: Equatable { | ||
public static func == (l: UInt160, r: UInt160) -> Bool { | ||
return l.u32 == r.u32 | ||
} | ||
|
||
public static func != (l: UInt160, r: UInt160) -> Bool { | ||
return l.u32 != r.u32 | ||
} | ||
} | ||
|
||
extension UInt256: Equatable { | ||
public static func == (l: UInt256, r: UInt256) -> Bool { | ||
return l.u64 == r.u64 | ||
} | ||
|
||
public static func != (l: UInt256, r: UInt256) -> Bool { | ||
return l.u64 != r.u64 | ||
} | ||
|
||
var hexString: String { | ||
var u = self | ||
return withUnsafePointer(to: &u) { p in | ||
Data(bytes: p, count: MemoryLayout<UInt256>.stride).hexString | ||
} | ||
} | ||
} | ||
|
||
extension UInt512: Equatable { | ||
public static func == (l: UInt512, r: UInt512) -> Bool { | ||
return l.u64 == r.u64 | ||
} | ||
|
||
public static func != (l: UInt512, r: UInt512) -> Bool { | ||
return l.u64 != r.u64 | ||
} | ||
} |
Oops, something went wrong.