-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: start refactoring fix: native desc wallets wild card address import was broekn
- Loading branch information
Showing
33 changed files
with
270 additions
and
1,288 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
Binary file not shown.
Binary file added
BIN
+110 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/1024_fully noded logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added
BIN
+9.58 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/128_fully noded logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added
BIN
+1.45 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/16_fully noded logo copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+20.3 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/256_fully noded logo copy 5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+20.3 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/256_fully noded logo copy 5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.5 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/32_fully noded logo copy-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.5 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/32_fully noded logo copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+46 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/512_fully noded logo-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/512_fully noded logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added
BIN
+4.7 KB
FullyNoded/Assets.xcassets/AppIcon-6.appiconset/64_fully noded logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,111 @@ | ||
// | ||
// OnchainUtils.swift | ||
// FullyNoded | ||
// | ||
// Created by Peter Denton on 8/13/21. | ||
// Copyright © 2021 Fontaine. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
class OnchainUtils { | ||
static func getDescriptorInfo(_ desc: String, completion: @escaping ((descriptorInfo: DescriptorInfo?, message: String?)) -> Void) { | ||
Reducer.makeCommand(command: .getdescriptorinfo, param: "\"\(desc)\"") { (response, message) in | ||
guard let response = response as? [String:Any] else { | ||
completion((nil, message ?? "Unknown error.")) | ||
return | ||
} | ||
|
||
completion((DescriptorInfo(response), nil)) | ||
} | ||
} | ||
|
||
static func importDescriptors(_ param: String, completion: @escaping ((imported: Bool, message: String?)) -> Void) { | ||
Reducer.makeCommand(command: .importdescriptors, param: param) { (response, message) in | ||
guard let responseArray = response as? [[String:Any]] else { | ||
completion((false, "Error importing descriptors: \(message ?? "unknown error")")) | ||
return | ||
} | ||
|
||
var warnings:String? | ||
|
||
for (i, response) in responseArray.enumerated() { | ||
var errorMessage = "" | ||
|
||
guard let success = response["success"] as? Bool, success else { | ||
if let error = response["error"] as? [String:Any], let messageCheck = error["message"] as? String { | ||
errorMessage = "Error importing descriptors: \(messageCheck)" | ||
} | ||
|
||
completion((false, errorMessage)) | ||
return | ||
} | ||
|
||
if let warningsCheck = response["warnings"] as? [String] { | ||
warnings = warningsCheck.description | ||
} | ||
|
||
if i + 1 == responseArray.count { | ||
completion((true, warnings)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
static func importMulti(_ param: String, completion: @escaping ((imported: Bool, message: String?)) -> Void) { | ||
Reducer.makeCommand(command: .importmulti, param: param) { (response, errorDescription) in | ||
guard let result = response as? NSArray, result.count > 0, | ||
let dict = result[0] as? NSDictionary, | ||
let success = dict["success"] as? Bool, | ||
success else { | ||
completion((false, errorDescription ?? "unknown error importing your keys")) | ||
return | ||
} | ||
|
||
completion((success, nil)) | ||
} | ||
} | ||
|
||
static func rescan(completion: @escaping ((started: Bool, message: String?)) -> Void) { | ||
OnchainUtils.getBlockchainInfo { (blockchainInfo, message) in | ||
guard let blockchainInfo = blockchainInfo else { | ||
completion((false, message)) | ||
return | ||
} | ||
|
||
guard blockchainInfo.pruned else { | ||
OnchainUtils.rescanNow(from: "0") { (started, message) in | ||
completion((started, message)) | ||
} | ||
|
||
return | ||
} | ||
|
||
OnchainUtils.rescanNow(from: "\(blockchainInfo.pruneheight)") { (started, message) in | ||
completion((started, message)) | ||
} | ||
} | ||
} | ||
|
||
static func getBlockchainInfo(completion: @escaping ((blockchainInfo: BlockchainInfo?, message: String?)) -> Void) { | ||
Reducer.makeCommand(command: .getblockchaininfo, param: "") { (response, errorMessage) in | ||
guard let dict = response as? [String:Any] else { | ||
completion((nil, errorMessage)) | ||
return | ||
} | ||
|
||
completion((BlockchainInfo(dict), errorMessage)) | ||
} | ||
} | ||
|
||
static func rescanNow(from: String, completion: @escaping ((started: Bool, message: String?)) -> Void) { | ||
Reducer.makeCommand(command: .rescanblockchain, param: "0") { (_, message) in | ||
if let message = message, message.contains("Wallet is currently rescanning. Abort existing rescan or wait.") { | ||
completion((true, nil)) | ||
} else { | ||
completion((true, message)) | ||
} | ||
} | ||
} | ||
|
||
} |
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,46 @@ | ||
// | ||
// DescriptorInfo.swift | ||
// FullyNoded | ||
// | ||
// Created by Peter Denton on 8/13/21. | ||
// Copyright © 2021 Fontaine. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct DescriptorInfo: CustomStringConvertible { | ||
|
||
/* | ||
{ (json object) | ||
"descriptor" : "str", (string) The descriptor in canonical form, without private keys | ||
"checksum" : "str", (string) The checksum for the input descriptor | ||
"isrange" : true|false, (boolean) Whether the descriptor is ranged | ||
"issolvable" : true|false, (boolean) Whether the descriptor is solvable | ||
"hasprivatekeys" : true|false (boolean) Whether the input descriptor contained at least one private key | ||
} | ||
*/ | ||
|
||
let checksum: String | ||
let hasprivatekeys: Bool | ||
let issolvable: Bool | ||
let isrange: Bool | ||
let descriptor: String | ||
|
||
init(_ dictionary: [String: Any]) { | ||
hasprivatekeys = dictionary["hasprivatekeys"] as! Bool | ||
checksum = dictionary["checksum"] as! String | ||
|
||
if hasprivatekeys { | ||
descriptor = (dictionary["descriptor"] as! String) + "#" + checksum | ||
} else { | ||
descriptor = (dictionary["descriptor"] as! String) | ||
} | ||
|
||
issolvable = dictionary["issolvable"] as! Bool | ||
isrange = dictionary["isrange"] as! Bool | ||
} | ||
|
||
public var description: String { | ||
return "" | ||
} | ||
} |
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
Oops, something went wrong.