Skip to content

Commit

Permalink
Merge pull request #555 from dashpay/develop
Browse files Browse the repository at this point in the history
chore: Merge Develop into Master
  • Loading branch information
pankcuf authored Jul 31, 2024
2 parents 3edd980 + 8d73d4b commit c0bcaf0
Show file tree
Hide file tree
Showing 49 changed files with 1,432 additions and 823 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
${{ runner.os }}-pods-
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '13.2.1'
xcode-version: '15.4'
- name: Rustup add targets
run: rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
- name: Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ - (void)verifySeedPharse {
oldData = getKeychainData(EXTENDED_0_PUBKEY_KEY_BIP44_V0, nil);
}

NSData *seed = [bip39Mnemonic deriveKeyFromPhrase:[bip39Mnemonic normalizePhrase:phrase] withPassphrase:nil];
//NSData *seed = [bip39Mnemonic deriveKeyFromPhrase:[bip39Mnemonic normalizePhrase:phrase] withPassphrase:nil];
DSWallet *transientWallet = [DSWallet standardWalletWithSeedPhrase:phrase setCreationDate:[NSDate timeIntervalSince1970] forChain:chain storeSeedPhrase:NO isTransient:YES];
DSAccount *transientAccount = [transientWallet accountWithNumber:0];
DSDerivationPath *transientDerivationPath = [transientAccount bip44DerivationPath];
Expand Down
20 changes: 15 additions & 5 deletions DashSync/shared/Categories/NSData/NSData+Dash.m
Original file line number Diff line number Diff line change
Expand Up @@ -1188,17 +1188,23 @@ - (uint8_t)UInt8AtOffset:(NSUInteger)offset {

- (uint16_t)UInt16AtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(uint16_t)) return 0;
return CFSwapInt16LittleToHost(*(const uint16_t *)((const uint8_t *)self.bytes + offset));
uint16_t value;
memcpy(&value, (const uint8_t *)self.bytes + offset, sizeof(uint16_t));
return CFSwapInt16LittleToHost(value);
}

- (uint16_t)UInt16BigToHostAtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(uint16_t)) return 0;
return CFSwapInt16BigToHost(*(const uint16_t *)((const uint8_t *)self.bytes + offset));
uint16_t value;
memcpy(&value, (const uint8_t *)self.bytes + offset, sizeof(uint16_t));
return CFSwapInt16BigToHost(value);
}

- (uint32_t)UInt32AtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(uint32_t)) return 0;
return CFSwapInt32LittleToHost(*(const uint32_t *)((const uint8_t *)self.bytes + offset));
uint32_t value;
memcpy(&value, (const uint8_t *)self.bytes + offset, sizeof(uint32_t));
return CFSwapInt32LittleToHost(value);
}

- (uint32_t)UInt32BigToHostAtOffset:(NSUInteger)offset {
Expand All @@ -1208,12 +1214,16 @@ - (uint32_t)UInt32BigToHostAtOffset:(NSUInteger)offset {

- (uint64_t)UInt64AtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(uint64_t)) return 0;
return CFSwapInt64LittleToHost(*(const uint64_t *)((const uint8_t *)self.bytes + offset));
uint64_t value;
memcpy(&value, (const uint8_t *)self.bytes + offset, sizeof(uint64_t));
return CFSwapInt64LittleToHost(value);
}

- (int64_t)Int64AtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(int64_t)) return 0;
return CFSwapInt64LittleToHost(*(const int64_t *)((const uint8_t *)self.bytes + offset));
uint64_t value;
memcpy(&value, (const uint8_t *)self.bytes + offset, sizeof(uint64_t));
return CFSwapInt64LittleToHost(value);
}

- (UInt128)UInt128AtOffset:(NSUInteger)offset {
Expand Down
8 changes: 3 additions & 5 deletions DashSync/shared/Categories/NSString+Bitcoin.m
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,11 @@ - (NSData *)base58ToData {

- (NSData *)base58checkToData {
NSData *d = self.base58ToData;

if (d.length < 4) return nil;

NSData *data = CFBridgingRelease(CFDataCreate(SecureAllocator(), d.bytes, d.length - 4));

// verify checksum
if (*(uint32_t *)((const uint8_t *)d.bytes + d.length - 4) != data.SHA256_2.u32[0]) return nil;
uint32_t checksum;
memcpy(&checksum, (const uint8_t *)d.bytes + d.length - 4, sizeof(uint32_t));
if (checksum != data.SHA256_2.u32[0]) return nil;
return data;
}

Expand Down
1 change: 1 addition & 0 deletions DashSync/shared/DashSync.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#import "DSPriceManager.h"
#import "DSShapeshiftManager.h"
#import "DSSporkManager.h"
#import "DSSyncState.h"
#import "DSTransactionManager.h"
#import "DSVersionManager.h"
#import "DSWallet.h"
Expand Down
15 changes: 6 additions & 9 deletions DashSync/shared/DashSync.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "DSMerkleBlockEntity+CoreDataClass.h"
#import "DSPeerEntity+CoreDataClass.h"
#import "DSPeerManager+Protected.h"
#import "DSSyncState.h"
#import "DSQuorumEntryEntity+CoreDataClass.h"
#import "DSQuorumSnapshotEntity+CoreDataClass.h"
#import "DSSporkManager+Protected.h"
Expand Down Expand Up @@ -168,12 +169,10 @@ - (void)wipeBlockchainDataForChain:(DSChain *)chain inContext:(NSManagedObjectCo
[DSDashpayUserEntity deleteContactsOnChainEntity:chainEntity]; // this must move after wipeBlockchainInfo where blockchain identities are removed
[context ds_save];
[chain reloadDerivationPaths];
[chain.chainManager assignSyncWeights];
[chain.chainManager notifySyncStateChanged];

dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:DSWalletBalanceDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:DSChainChainSyncBlocksDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:DSChainTerminalBlocksDidChangeNotification object:nil];
});
}];
}
Expand All @@ -198,12 +197,10 @@ - (void)wipeBlockchainNonTerminalDataForChain:(DSChain *)chain inContext:(NSMana
[DSDashpayUserEntity deleteContactsOnChainEntity:chainEntity]; // this must move after wipeBlockchainInfo where blockchain identities are removed
[context ds_save];
[chain reloadDerivationPaths];
[chain.chainManager assignSyncWeights];
[chain.chainManager notifySyncStateChanged];

dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:DSWalletBalanceDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:DSChainChainSyncBlocksDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:DSChainTerminalBlocksDidChangeNotification object:nil];
});
}];
}
Expand All @@ -222,7 +219,7 @@ - (void)wipeMasternodeDataForChain:(DSChain *)chain inContext:(NSManagedObjectCo
DSChainManager *chainManager = [[DSChainsManager sharedInstance] chainManagerForChain:chain];
[chainManager wipeMasternodeInfo];
[context ds_save];
[chain.chainManager assignSyncWeights];
[chain.chainManager notifySyncStateChanged];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:[NSString stringWithFormat:@"%@_%@", chain.uniqueID, LAST_SYNCED_MASTERNODE_LIST]];
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:DSMasternodeListDidChangeNotification object:nil userInfo:@{DSChainManagerNotificationChainKey: chain}];
Expand Down Expand Up @@ -325,7 +322,7 @@ - (void)scheduleBackgroundFetch {

- (void)performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
DSChainManager *mainnetManager = [[DSChainsManager sharedInstance] mainnetManager];
if (mainnetManager.chainSyncProgress >= 1.0) {
if (mainnetManager.syncState.chainSyncProgress >= 1.0) {
DSLog(@"Background fetch: already synced");

if (completionHandler) {
Expand Down Expand Up @@ -374,7 +371,7 @@ - (void)performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))com
}

- (void)backgroundFetchTimedOut {
const double syncProgress = [[DSChainsManager sharedInstance] mainnetManager].chainSyncProgress;
const double syncProgress = [[DSChainsManager sharedInstance] mainnetManager].syncState.chainSyncProgress;
DSLog(@"Background fetch timeout with progress: %f", syncProgress);

const UIBackgroundFetchResult fetchResult = syncProgress > 0.1 ? UIBackgroundFetchResultNewData : UIBackgroundFetchResultFailed;
Expand Down
32 changes: 32 additions & 0 deletions DashSync/shared/MainnetFixedPeers.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<integer>3263651171</integer>
<integer>148804577</integer>
<integer>759996581</integer>
<integer>2994784866</integer>
<integer>2673411509</integer>
<integer>2297634243</integer>
<integer>1588652144</integer>
<integer>2178245180</integer>
<integer>2671888933</integer>
<integer>94492658</integer>
<integer>3156785217</integer>
<integer>759997248</integer>
<integer>3156779795</integer>
<integer>3156782919</integer>
<integer>3156743658</integer>
<integer>1389566409</integer>
<integer>2461642608</integer>
<integer>2297663013</integer>
<integer>1097723841</integer>
<integer>1389566384</integer>
<integer>2335935255</integer>
<integer>822870522</integer>
<integer>1608023587</integer>
<integer>1311700836</integer>
<integer>759130970</integer>
<integer>2178245360</integer>
</array>
</plist>
4 changes: 1 addition & 3 deletions DashSync/shared/Models/Chain/DSChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@ NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXPORT NSString *const DSChainWalletsDidChangeNotification;
FOUNDATION_EXPORT NSString *const DSChainStandaloneDerivationPathsDidChangeNotification;
FOUNDATION_EXPORT NSString *const DSChainStandaloneAddressesDidChangeNotification;
FOUNDATION_EXPORT NSString *const DSChainChainSyncBlocksDidChangeNotification;
FOUNDATION_EXPORT NSString *const DSChainBlockWasLockedNotification;
FOUNDATION_EXPORT NSString *const DSChainNotificationBlockKey;

// For improved performance DSChainInitialHeadersDidChangeNotification is not garanteed to trigger on every initial headers change.
FOUNDATION_EXPORT NSString *const DSChainTerminalBlocksDidChangeNotification;
FOUNDATION_EXPORT NSString *const DSChainInitialHeadersDidFinishSyncingNotification;
FOUNDATION_EXPORT NSString *const DSChainBlocksDidFinishSyncingNotification;
FOUNDATION_EXPORT NSString *const DSChainNewChainTipBlockNotification;

typedef NS_ENUM(NSUInteger, DSTransactionDirection)
{
Expand Down Expand Up @@ -504,6 +501,7 @@ typedef NS_ENUM(uint16_t, DSChainSyncPhase)

@required

- (void)chainWillStartConnectingToPeers:(DSChain *)chain;
- (void)chainWillStartSyncingBlockchain:(DSChain *)chain;
- (void)chainShouldStartSyncingBlockchain:(DSChain *)chain onPeer:(DSPeer *)peer;
- (void)chainFinishedSyncingTransactionsAndBlocks:(DSChain *)chain fromPeer:(DSPeer *_Nullable)peer onMainChain:(BOOL)onMainChain;
Expand Down
Loading

0 comments on commit c0bcaf0

Please sign in to comment.