Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DashSync.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Pod::Spec.new do |s|
s.ios.framework = 'UIKit'
s.macos.framework = 'Cocoa'
s.compiler_flags = '-Wno-comma'
s.dependency 'DashSharedCore', '0.4.14'
s.dependency 'DashSharedCore', '0.4.15'
s.dependency 'CocoaLumberjack', '3.7.2'
s.ios.dependency 'DWAlertController', '0.2.1'
s.dependency 'DSDynamicOptions', '0.1.2'
Expand Down
1 change: 1 addition & 0 deletions DashSync/shared/Categories/NSData/NSData+Dash.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ size_t chacha20Poly1305AEADDecrypt(void *_Nullable out, size_t outLen, const voi
- (uint32_t)UInt32AtOffset:(NSUInteger)offset;
- (uint32_t)UInt32BigToHostAtOffset:(NSUInteger)offset;
- (uint64_t)UInt64AtOffset:(NSUInteger)offset;
- (int64_t)Int64AtOffset:(NSUInteger)offset;
- (UInt128)UInt128AtOffset:(NSUInteger)offset;
- (UInt160)UInt160AtOffset:(NSUInteger)offset;
- (UInt256)UInt256AtOffset:(NSUInteger)offset;
Expand Down
5 changes: 5 additions & 0 deletions DashSync/shared/Categories/NSData/NSData+Dash.m
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,11 @@ - (uint64_t)UInt64AtOffset:(NSUInteger)offset {
return CFSwapInt64LittleToHost(*(const uint64_t *)((const uint8_t *)self.bytes + offset));
}

- (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));
}

- (UInt128)UInt128AtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(UInt128)) return UINT128_ZERO;
return *(UInt128 *)(self.bytes + offset);
Expand Down
1 change: 1 addition & 0 deletions DashSync/shared/Models/Chain/DSChain.m
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,7 @@ - (DSBloomFilter *)bloomFilterWithFalsePositiveRate:(double)falsePositiveRate wi
[allAddresses addObjectsFromArray:[wallet providerOwnerAddresses]];
[allAddresses addObjectsFromArray:[wallet providerVotingAddresses]];
[allAddresses addObjectsFromArray:[wallet providerOperatorAddresses]];
[allAddresses addObjectsFromArray:[wallet platformNodeAddresses]];
}

for (DSFundsDerivationPath *derivationPath in self.standaloneDerivationPaths) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ - (void)updateTransactionsBloomFilter {
[allAddressesArray addObjectsFromArray:[wallet providerOwnerAddresses]];
[allAddressesArray addObjectsFromArray:[wallet providerVotingAddresses]];
[allAddressesArray addObjectsFromArray:[wallet providerOperatorAddresses]];
[allAddressesArray addObjectsFromArray:[wallet platformNodeAddresses]];
}

for (DSFundsDerivationPath *derivationPath in self.chain.standaloneDerivationPaths) {
Expand Down Expand Up @@ -1216,11 +1217,7 @@ - (void)peer:(DSPeer *)peer relayedTransaction:(DSTransaction *)transaction inBl
#endif
}

if (block) {
transaction.timestamp = block.timestamp;
} else {
transaction.timestamp = [NSDate timeIntervalSince1970];
}
transaction.timestamp = block ? block.timestamp : [NSDate timeIntervalSince1970];
NSArray<DSAccount *> *accounts = [self.chain accountsThatCanContainTransaction:transaction];
NSMutableArray<DSAccount *> *accountsAcceptingTransaction = [NSMutableArray array];
NSMutableArray<DSAccount *> *accountsWithValidTransaction = [NSMutableArray array];
Expand Down
5 changes: 2 additions & 3 deletions DashSync/shared/Models/Masternode/DSMasternodeListStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ - (void)notifyMasternodeListUpdate {
- (void)saveMasternodeList:(DSMasternodeList *)masternodeList addedMasternodes:(NSDictionary *)addedMasternodes modifiedMasternodes:(NSDictionary *)modifiedMasternodes completion:(void (^)(NSError *error))completion {
UInt256 blockHash = masternodeList.blockHash;
NSData *blockHashData = uint256_data(blockHash);
DSLog(@"•••• store (%d) masternode list at: %u: %@", [self hasMasternodeListAt:blockHashData], [self heightForBlockHash:blockHash], uint256_hex(blockHash));
if ([self hasMasternodeListAt:blockHashData]) {
// in rare race conditions this might already exist
// but also as we can get it from different sources
Expand Down Expand Up @@ -524,7 +523,7 @@ + (void)saveMasternodeList:(DSMasternodeList *)masternodeList
createUnknownBlocks:(BOOL)createUnknownBlocks
inContext:(NSManagedObjectContext *)context
completion:(void (^)(NSError *error))completion {
DSLog(@"Queued saving MNL at height %u", masternodeList.height);
DSLog(@"Queued saving MNL at height %u: %@", masternodeList.height, uint256_hex(masternodeList.blockHash));
[context performBlockAndWait:^{
//masternodes
@autoreleasepool {
Expand Down Expand Up @@ -607,7 +606,7 @@ + (void)saveMasternodeList:(DSMasternodeList *)masternodeList
}
}
chainEntity.baseBlockHash = mnlBlockHashData;
DSLog(@"Finished merging MNL at height %u", mnlHeight);
DSLog(@"Finished merging MNL at height %u: %@", mnlHeight, mnlBlockHashData.hexString);

} else if (!error) {
DSMasternodeListEntity *masternodeListEntity = [DSMasternodeListEntity managedObjectInBlockedContext:context];
Expand Down
17 changes: 9 additions & 8 deletions DashSync/shared/Models/Network/DSPeer.m
Original file line number Diff line number Diff line change
Expand Up @@ -755,13 +755,14 @@ - (void)acceptMessage:(NSData *)message type:(NSString *)type {
DSLog(@"%@:%u accept message %@", self.host, self.port, type);
}
#endif
if (self.currentBlock && (!([MSG_TX isEqual:type] || [MSG_IX isEqual:type] || [MSG_ISLOCK isEqual:type]))) { // if we receive a non-tx message, merkleblock is done
if (self.currentBlock && (!([MSG_TX isEqual:type] || [MSG_IX isEqual:type] || [MSG_ISLOCK isEqual:type]))) {
// if we receive a non-tx message, merkleblock is done
UInt256 hash = self.currentBlock.blockHash;

NSUInteger txExpected = self.currentBlockTxHashes.count;
self.currentBlock = nil;
self.currentBlockTxHashes = nil;
[self error:@"incomplete merkleblock %@, expected %u more tx, got %@",
uint256_obj(hash), (int)self.currentBlockTxHashes.count, type];
[self error:@"incomplete merkleblock %@, expected %lu more tx, got %@",
uint256_obj(hash), txExpected, type];
} else if ([MSG_VERSION isEqual:type])
[self acceptVersionMessage:message];
else if ([MSG_VERACK isEqual:type])
Expand Down Expand Up @@ -1264,9 +1265,9 @@ - (void)acceptTxMessage:(NSData *)message {
#endif
#else
#if DEBUG
DSLogPrivate(@"%@:%u got tx %@", self.host, self.port, uint256_obj(tx.txHash));
DSLogPrivate(@"%@:%u got tx (%lu): %@", self.host, self.port, tx.type, uint256_obj(tx.txHash));
#else
DSLog(@"%@:%u got tx %@", self.host, self.port, @"<REDACTED>");
DSLog(@"%@:%u got tx (%lu): %@", self.host, self.port, tx.type, @"<REDACTED>");
#endif
#endif
}
Expand Down Expand Up @@ -1639,8 +1640,8 @@ - (void)acceptMerkleblockMessage:(NSData *)message {
[self error:@"got merkleblock message before loading a filter"];
return;
}
//else DSLog(@"%@:%u got merkleblock %@", self.host, self.port, block.blockHash);

//else DSLog(@"%@:%u got merkleblock %@", self.host, self.port, uint256_hex(block.blockHash));
NSMutableOrderedSet *txHashes = [NSMutableOrderedSet orderedSetWithArray:block.transactionHashes];
@synchronized (self.knownTxHashes) {
[txHashes minusOrderedSet:self.knownTxHashes];
Expand Down
2 changes: 1 addition & 1 deletion DashSync/shared/Models/Transactions/Base/DSTransaction.m
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ - (NSArray *)outputAddresses {

- (NSString *)description {
NSString *txid = [NSString hexWithData:[NSData dataWithBytes:self.txHash.u8 length:sizeof(UInt256)].reverse];
return [NSString stringWithFormat:@"%@(id=%@-block=%@) + (%@)", [self class], txid, (self.blockHeight == TX_UNCONFIRMED) ? @"Not mined" : @(self.blockHeight), [super description]];
return [NSString stringWithFormat:@"%@(id=%@-block=%@)", [super description], txid, (self.blockHeight == TX_UNCONFIRMED) ? @"Not mined" : @(self.blockHeight)];
}

- (NSString *)longDescription {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@property (nonatomic, assign) uint32_t height;
@property (nonatomic, assign) UInt256 merkleRootMNList;
@property (nonatomic, assign) UInt256 merkleRootLLMQList;
@property (nonatomic, assign) uint32_t bestCLHeightDiff;
@property (nonatomic, assign) NSUInteger bestCLHeightDiff;
@property (nonatomic, assign) UInt768 bestCLSignature;
@property (nonatomic, assign) int64_t creditPoolBalance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ - (instancetype)initWithMessage:(NSData *)message onChain:(DSChain *)chain {
off += 32;

if (version >= COINBASE_TX_CORE_20) {
if (length - off < 4) return nil;
self.bestCLHeightDiff = [message UInt32AtOffset:off];
off += 4;
NSNumber *len;
self.bestCLHeightDiff = [message varIntAtOffset:off length:&len];
off += len.unsignedIntegerValue;
if (length - off < 96) return nil;
self.bestCLSignature = [message UInt768AtOffset:off];
off += 96;
if (length - off < 8) return nil;
NSNumber *len;
self.creditPoolBalance = [message varIntAtOffset:off length:&len];
self.creditPoolBalance = [message Int64AtOffset:off];
off += len.unsignedIntegerValue;
}
}
Expand Down Expand Up @@ -93,7 +92,7 @@ - (NSData *)payloadData {
if (self.coinbaseTransactionVersion >= COINBASE_TX_CORE_19) {
[data appendUInt256:self.merkleRootLLMQList];
if (self.coinbaseTransactionVersion >= COINBASE_TX_CORE_20) {
[data appendUInt32:self.bestCLHeightDiff];
[data appendVarInt:self.bestCLHeightDiff];
// TODO: check whether it matters to check for optionals
[data appendUInt768:self.bestCLSignature];
[data appendInt64:self.creditPoolBalance];
Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,11 @@ PODS:
- "!ProtoCompiler-gRPCPlugin (~> 1.0)"
- DAPI-GRPC/Messages
- gRPC-ProtoRPC
- DashSharedCore (0.4.14)
- DashSharedCore (0.4.15)
- DashSync (0.1.0):
- CocoaLumberjack (= 3.7.2)
- DAPI-GRPC (= 0.22.0-dev.8)
- DashSharedCore (= 0.4.14)
- DashSharedCore (= 0.4.15)
- DSDynamicOptions (= 0.1.2)
- DWAlertController (= 0.2.1)
- TinyCborObjc (= 0.4.6)
Expand Down Expand Up @@ -712,8 +712,8 @@ SPEC CHECKSUMS:
CocoaImageHashing: 8656031d0899abe6c1c415827de43e9798189c53
CocoaLumberjack: b7e05132ff94f6ae4dfa9d5bce9141893a21d9da
DAPI-GRPC: 138d62523bbfe7e88a39896f1053c0bc12390d9f
DashSharedCore: dc766715605effeed166d39701825bd1f4c3c500
DashSync: 3c7c4c0385b8c18dd764c0ef63fc02eef1c38f4f
DashSharedCore: 837242d84149ee9d1cce1037cc583751553421fa
DashSync: 9c5355f4cd18808ef1eeb0d61cce174f52a1f27f
DSDynamicOptions: 347cc5d2c4e080eb3de6a86719ad3d861b82adfc
DWAlertController: 5f4cd8adf90336331c054857f709f5f8d4b16a5b
gRPC: 64f36d689b2ecd99c4351f74e6f91347cdc65d9f
Expand Down
Loading