Skip to content

Commit

Permalink
Merge pull request #2 from Fonta1n3/v0.0.2
Browse files Browse the repository at this point in the history
V0.0.2
  • Loading branch information
Fonta1n3 authored Jul 24, 2024
2 parents 03dbdc4 + cfe747e commit d92fdea
Show file tree
Hide file tree
Showing 14 changed files with 311 additions and 64 deletions.
32 changes: 16 additions & 16 deletions UnifyWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
0A832A532C33906D00F25C46 /* DescriptorInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DescriptorInfo.swift; sourceTree = "<group>"; };
0A832A552C3395A500F25C46 /* Keys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keys.swift; sourceTree = "<group>"; };
0A832A572C33B1D400F25C46 /* NetworkInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkInfo.swift; sourceTree = "<group>"; };
0A9AB0F52C3B198E002551E2 /* UnifyWalletmacOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UnifyWalletmacOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
0A9AB0F52C3B198E002551E2 /* UnifyWalletDesktop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UnifyWalletDesktop.app; sourceTree = BUILT_PRODUCTS_DIR; };
2A0C438B71D5FD0248DF6734 /* Pods_UnifyWalletmacOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_UnifyWalletmacOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
560ADF9DDDB431D7C6A7E9BC /* Pods_UnifyWallet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_UnifyWallet.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AE13A5377A734BAA9755D892 /* Pods-UnifyWallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnifyWallet.debug.xcconfig"; path = "Target Support Files/Pods-UnifyWallet/Pods-UnifyWallet.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -285,7 +285,7 @@
isa = PBXGroup;
children = (
0A8329C82C29F00F00F25C46 /* UnifyWallet.app */,
0A9AB0F52C3B198E002551E2 /* UnifyWalletmacOS.app */,
0A9AB0F52C3B198E002551E2 /* UnifyWalletDesktop.app */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -506,9 +506,9 @@
productReference = 0A8329C82C29F00F00F25C46 /* UnifyWallet.app */;
productType = "com.apple.product-type.application";
};
0A9AB0B12C3B198E002551E2 /* UnifyWalletmacOS */ = {
0A9AB0B12C3B198E002551E2 /* UnifyWalletDesktop */ = {
isa = PBXNativeTarget;
buildConfigurationList = 0A9AB0F22C3B198E002551E2 /* Build configuration list for PBXNativeTarget "UnifyWalletmacOS" */;
buildConfigurationList = 0A9AB0F22C3B198E002551E2 /* Build configuration list for PBXNativeTarget "UnifyWalletDesktop" */;
buildPhases = (
CCFC471BD4CF29F863132118 /* [CP] Check Pods Manifest.lock */,
0A9AB0B62C3B198E002551E2 /* Sources */,
Expand All @@ -521,13 +521,13 @@
);
dependencies = (
);
name = UnifyWalletmacOS;
name = UnifyWalletDesktop;
packageProductDependencies = (
0A9AB0B22C3B198E002551E2 /* NostrSDK */,
0A9AB0B42C3B198E002551E2 /* SwiftUICoreImage */,
);
productName = UnifyWallet;
productReference = 0A9AB0F52C3B198E002551E2 /* UnifyWalletmacOS.app */;
productReference = 0A9AB0F52C3B198E002551E2 /* UnifyWalletDesktop.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand Down Expand Up @@ -563,7 +563,7 @@
projectRoot = "";
targets = (
0A8329C72C29F00F00F25C46 /* UnifyWallet */,
0A9AB0B12C3B198E002551E2 /* UnifyWalletmacOS */,
0A9AB0B12C3B198E002551E2 /* UnifyWalletDesktop */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -922,7 +922,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = UnifyWallet/UnifyWallet.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"UnifyWallet/Preview Content\"";
DEVELOPMENT_TEAM = 8JHDU5M9KD;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -950,7 +950,7 @@
"LD_RUNPATH_SEARCH_PATHS[sdk=iphoneos*]" = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 0.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.dentonllc.UnifyWallet;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand All @@ -971,7 +971,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = UnifyWallet/UnifyWallet.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"UnifyWallet/Preview Content\"";
DEVELOPMENT_TEAM = 8JHDU5M9KD;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -998,7 +998,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0.1;
MARKETING_VERSION = 0.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.dentonllc.UnifyWallet;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand All @@ -1019,7 +1019,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = UnifyWallet/UnifyWallet.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"UnifyWallet/Preview Content\"";
DEVELOPMENT_TEAM = 8JHDU5M9KD;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1046,7 +1046,7 @@
"LD_RUNPATH_SEARCH_PATHS[sdk=iphoneos*]" = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.0.1;
MARKETING_VERSION = 0.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.dentonllc.UnifyWallet;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand All @@ -1066,7 +1066,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = UnifyWallet/UnifyWallet.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_ASSET_PATHS = "\"UnifyWallet/Preview Content\"";
DEVELOPMENT_TEAM = 8JHDU5M9KD;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1092,7 +1092,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.0.1;
MARKETING_VERSION = 0.0.2;
PRODUCT_BUNDLE_IDENTIFIER = com.dentonllc.UnifyWallet;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down Expand Up @@ -1125,7 +1125,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
0A9AB0F22C3B198E002551E2 /* Build configuration list for PBXNativeTarget "UnifyWalletmacOS" */ = {
0A9AB0F22C3B198E002551E2 /* Build configuration list for PBXNativeTarget "UnifyWalletDesktop" */ = {
isa = XCConfigurationList;
buildConfigurations = (
0A9AB0F32C3B198E002551E2 /* Debug */,
Expand Down
24 changes: 12 additions & 12 deletions UnifyWallet/BitcoinCore/BitcoinCoreRPC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ class BitcoinCoreRPC {
}

var request = URLRequest(url: url)
var timeout = 10.0

switch method.stringValue {
case "gettxoutsetinfo":
timeout = 1000.0

case "importmulti", "deriveaddresses", "loadwallet":
timeout = 60.0

default:
break
}
let timeout = 60.0

// switch method.stringValue {
// case "gettxoutsetinfo":
// timeout = 1000.0
//
// case "importmulti", "deriveaddresses", "loadwallet":
// timeout = 60.0
//
// default:
// break
// }

let loginString = String(format: "%@:%@", "PayJoin", rpcPass)
let loginData = loginString.data(using: String.Encoding.utf8)!
Expand Down
14 changes: 14 additions & 0 deletions UnifyWallet/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ public extension String {
let components = self.components(separatedBy: .whitespacesAndNewlines)
return components.filter { !$0.isEmpty }.joined(separator: " ")
}

var withSpaces: String {
var addressToDisplay = ""
for (i, c) in self.enumerated() {
addressToDisplay += "\(c)"
if i > 0 && i < self.count - 2 {
if i.isMultiple(of: 4) {
addressToDisplay += " - "
}
}
}
return addressToDisplay
}
}


Expand All @@ -42,6 +55,7 @@ public extension Double {
var btcBalanceWithSpaces: String {
var btcBalance = abs(self.rounded(toPlaces: 8)).avoidNotation
btcBalance = btcBalance.replacingOccurrences(of: ",", with: "")

if !btcBalance.contains(".") {
btcBalance += ".0"
}
Expand Down
19 changes: 19 additions & 0 deletions UnifyWallet/Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ import LibWally

enum Keys {

static func donationAddress() -> String? {
let randomInt = Int.random(in: 0..<100)



let networkSetting = UserDefaults.standard.object(forKey: "network") as? String ?? "Signet"
var network: Network = .testnet

if networkSetting == "Mainnet" {
network = .mainnet
}

guard let hdKey = try? HDKey(base58: "xpub6C1DcRZo4RfYHE5F4yiA2m26wMBLr33qP4xpVdzY1EkHyUdaxwHhAvAUpohwT4ajjd1N9nt7npHrjd3CLqzgfbEYPknaRW8crT2C9xmAy3G"),
let path = try? BIP32Path(string: "0/\(randomInt)"),
let address = try? hdKey.derive(using: path).address(type: .payToWitnessPubKeyHash), let x = try? Address(scriptPubKey: address.scriptPubKey, network: network) else { return nil }

return x.description
}

static func seed() -> String? {
var words: String?
let bytesCount = 32
Expand Down
69 changes: 62 additions & 7 deletions UnifyWallet/UnifyWalletApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ struct UnifyWalletApp: App {
var body: some Scene {
WindowGroup {
HomeView()
#if os(iOS)
.onAppear(perform: UIApplication.shared.addTapGestureRecognizer)
#endif
}
}

Expand Down Expand Up @@ -55,24 +58,57 @@ struct UnifyWalletApp: App {
return
}

// MARK: Normal flow
// UserDefaults.standard.setValue("38332", forKey: "rpcPort")
// UserDefaults.standard.setValue("Signet", forKey: "network")
//
// guard let encRpcPass = Crypto.encrypt(Crypto.privKeyData()) else {
// showNotSavedAlert = true
// return
// }
//
// let dict: [String:Any] = [
// "rpcPass": encRpcPass,
// "rpcUser": "Unify",
// "rpcAddress": "127.0.0.1",
// "rpcPort": "38332"
// ]

// MARK: Demo mode
guard let rpcauthcreds = RPCAuth().generateCreds(username: "Unify", password: "1d52e89e0c16a7cc57cbda4954eebf4ba7864e113e5c8bbaa8ab662c8af9ce91") else {
showNotSavedAlert = true
return
}

UserDefaults.standard.setValue("38332", forKey: "rpcPort")
UserDefaults.standard.setValue("Signet", forKey: "network")

guard let encRpcPass = Crypto.encrypt(Crypto.privKeyData()) else {
UserDefaults.standard.setValue(true, forKey: "torEnabled")
UserDefaults.standard.setValue("FullyNoded-da09e4c7b0fc6187c2c1bd2ace56bad7ba25406da168d7b16b4793ef81a082f9", forKey: "walletName")
// Specify a wallet too.

let rpcpass = rpcauthcreds.password

guard let encRpcPass = Crypto.encrypt(rpcpass.data(using: .utf8)!) else {
showNotSavedAlert = true
return
}

let dict: [String:Any] = [
"rpcPass": encRpcPass,
"rpcUser": "Unify",
"rpcAddress": "127.0.0.1",
"rpcAddress": "rarokrtgsiwy42pcgmrp2sdslrt2efpt56rbhjvnwjnje2os64p3t5qd.onion",
"rpcPort": "38332"
]

saveCreds(entityName: "RPCCredentials", dict: dict)

createDefaultTorCreds()

let d = Data("smile pool offer seat betray sponsor build genius vault follow glad near".utf8)
guard let encryptedSigner = Crypto.encrypt(d) else { return }
DataManager.saveEntity(entityName: "BIP39Signer", dict: ["encryptedData": encryptedSigner]) { signerSaved in
guard signerSaved else { return }

saveCreds(entityName: "RPCCredentials", dict: dict)

createDefaultTorCreds()
}

return
}
Expand Down Expand Up @@ -112,3 +148,22 @@ struct UnifyWalletApp: App {
}
}
}

#if os(iOS)
extension UIApplication {
func addTapGestureRecognizer() {
guard let window = windows.first else { return }
let tapGesture = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing))
tapGesture.requiresExclusiveTouchType = false
tapGesture.cancelsTouchesInView = false
tapGesture.delegate = self
window.addGestureRecognizer(tapGesture)
}
}

extension UIApplication: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true // set to `false` if you don't want to detect tap during other gestures
}
}
#endif
4 changes: 3 additions & 1 deletion UnifyWallet/Views/History/HistoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ struct HistoryView: View {
#if os(macOS)
.scaleEffect(0.5)
#endif
.padding(.trailing)
} else {
Button() {
listTransactions()
} label: {
Image(systemName: "arrow.clockwise")
.foregroundStyle(.blue)
}
}
.padding(.trailing)
}
}
Form() {
List() {
Expand Down
Loading

0 comments on commit d92fdea

Please sign in to comment.