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
21 changes: 19 additions & 2 deletions DashSync/shared/DSDashSharedCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#import "DSChain+Wallet.h"
#import "DSChainLock.h"
#import "DSChainManager+Protected.h"
#import "DSDashPlatform.h"
#import "DSDashSharedCore.h"
#import "DSIdentity+Protected.h"
#import "DSKeyManager.h"
Expand Down Expand Up @@ -132,6 +133,10 @@ - (instancetype)initOnChain:(DSChain *)chain {
UpdateMasternodesAddressUsage update_address_usage_of_masternodes = {
.caller = &update_address_usage_of_masternodes_caller
};
Fn_ARGS_std_os_raw_c_void_data_contracts_SystemDataContract_RTRN_dpp_data_contract_DataContract get_data_contract_from_cache = {
.caller = &get_data_contract_from_cache_caller,
.destructor = &get_data_contract_from_cache_dtor
};

NSArray<NSString *> *addresses = @[@"127.0.0.1"];
switch (chain.chainType->tag) {
Expand All @@ -152,7 +157,7 @@ - (instancetype)initOnChain:(DSChain *)chain {
}
Vec_ *address_list = [NSArray ffi_to_vec:addresses];
dash_spv_masternode_processor_processing_processor_DiffConfig *diff_config = [chain createDiffConfig];
self.core = dash_spv_apple_bindings_DashSPVCore_with_callbacks(chain.chainType, diff_config, address_list, get_data_contract, get_platform_activation_height, callback_signer, callback_can_sign, get_block_height_by_hash, get_block_hash_by_height, update_address_usage_of_masternodes, context);
self.core = dash_spv_apple_bindings_DashSPVCore_with_callbacks(chain.chainType, diff_config, address_list, get_data_contract, get_platform_activation_height, callback_signer, callback_can_sign, get_data_contract_from_cache, get_block_height_by_hash, get_block_hash_by_height, update_address_usage_of_masternodes, context);
return self;
}

Expand All @@ -171,6 +176,18 @@ - (void)dealloc {
}
void get_data_contract_dtor(MaybeDataContract *result) {}

DDataContract *get_data_contract_from_cache_caller(const void *context, data_contracts_SystemDataContract *ty) {
DSDashSharedCore *core = AS_OBJC(context);
switch (ty[0]) {
case data_contracts_SystemDataContract_DPNS:
return [DSDashPlatform sharedInstanceForChain:core.chain].dpnsRawContract;
case data_contracts_SystemDataContract_Dashpay:
return [DSDashPlatform sharedInstanceForChain:core.chain].dashPayRawContract;
default: return NULL;
}
}
void get_data_contract_from_cache_dtor(DDataContract *result) {}

MaybeSignedData *callback_signer_caller(const void *context, DIdentityPublicKey *identity_public_key, Vec_u8 *data) {
DSDashSharedCore *core = AS_OBJC(context);
DBinaryData *ok = NULL;
Expand All @@ -184,7 +201,7 @@ void get_data_contract_dtor(MaybeDataContract *result) {}
ok = DBinaryDataCtor(DOpaqueKeyHashAndSign(maybe_key->ok, data));
}
DMaybeOpaqueKeyDtor(maybe_key);
dpp_identity_identity_public_key_IdentityPublicKey_destroy(identity_public_key);
DIdentityPublicKeyDtor(identity_public_key);
bytes_dtor(data);
return Result_ok_platform_value_types_binary_data_BinaryData_err_dpp_errors_protocol_error_ProtocolError_ctor(ok, error);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSError *)ffi_from_quorum_validation_error:(dashcore_sml_quorum_validation_error_QuorumValidationError *)ffi_ref;
@end

@interface NSError (dash_spv_platform_identity_username_registration_error_UsernameRegistrationError)
+ (NSError *)ffi_from_username_registration_error:(dash_spv_platform_identity_username_registration_error_UsernameRegistrationError *)ffi_ref;
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// limitations under the License.
//

#import "NSArray+Dash.h"
#import "NSData+Dash.h"
#import "NSError+Dash.h"
#import "NSError+Platform.h"
Expand All @@ -32,6 +33,8 @@ + (nonnull NSError *)ffi_from_platform_error:(nonnull DPlatformError *)ffi_ref {
case dash_spv_platform_error_Error_MaxRetryExceeded:
case dash_spv_platform_error_Error_InstantSendSignatureVerificationError:
return [NSError errorWithCode:0 localizedDescriptionKey:NSStringFromPtr(ffi_ref->instant_send_signature_verification_error)];
case dash_spv_platform_error_Error_UsernameRegistrationError:
return [NSError ffi_from_username_registration_error:ffi_ref->username_registration_error];
}
}

Expand Down Expand Up @@ -248,5 +251,19 @@ + (NSError *)ffi_from_sml_error:(dashcore_sml_error_SmlError *)ffi_ref {
}
@end

@implementation NSError (dash_spv_platform_identity_username_registration_error_UsernameRegistrationError)
+ (NSError *)ffi_from_username_registration_error:(dash_spv_platform_identity_username_registration_error_UsernameRegistrationError *)ffi_ref {

switch (ffi_ref->tag) {
case dash_spv_platform_identity_username_registration_error_UsernameRegistrationError_NoUsernameFullPathsWithStatus:
return [NSError errorWithCode:0 descriptionKey:DSLocalizedFormat(@"UsernameRegistrationError::NoUsernameFullPathsWithStatus(%u)", nil, DUsernameStatusIndex(ffi_ref->no_username_full_paths_with_status))];
case dash_spv_platform_identity_username_registration_error_UsernameRegistrationError_NoUsernamePreorderDocuments:
return [NSError errorWithCode:0 descriptionKey:DSLocalizedFormat(@"UsernameRegistrationError::NoUsernamePreorderDocuments(%u, %@)", nil, DUsernameStatusIndex(ffi_ref->no_username_preorder_documents._0), [NSArray ffi_from_vec_of_string:ffi_ref->no_username_preorder_documents._1])];
case dash_spv_platform_identity_username_registration_error_UsernameRegistrationError_NotSupported:
return [NSError errorWithCode:0 descriptionKey:DSLocalizedFormat(@"UsernameRegistrationError::NotSupported(%u)", nil, DUsernameStatusIndex(ffi_ref->not_supported))];
}
}
@end



4 changes: 2 additions & 2 deletions DashSync/shared/Models/CoinJoin/DSCoinJoinManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ - (void)stopAsync {

- (void)dealloc {
if (_options != NULL) {
free(_options);
dash_spv_coinjoin_models_coinjoin_client_options_CoinJoinClientOptions_destroy(_options);
}
}

Expand Down Expand Up @@ -733,7 +733,7 @@ - (double)getMixingProgress {
}

+ (BOOL)isDenominatedAmount:(uint64_t)amount {
return is_denominated_amount(amount);
return dash_spv_coinjoin_coinjoin_CoinJoin_is_denominated_amount(amount);
}

- (BOOL)isCoinJoinOutput:(DSTransactionOutput *)output utxo:(DSUTXO)utxo {
Expand Down
1 change: 1 addition & 0 deletions DashSync/shared/Models/CoinJoin/DSCoinJoinWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ bool hasChainLock(const void *context, uint32_t block_height) {
@synchronized (context) {
DSCoinJoinWrapper *wrapper = AS_OBJC(context);
DSTransaction *transaction = [wrapper.chain transactionForHash:txHash];
DSLog(@"[DSCoinJoinWrapper] getTransaction: %@ == %@ (%@)", uint256_hex(txHash), transaction, [wrapper.chain transactionForHash:uint256_reverse(txHash)]);
if (transaction)
tx = [transaction ffi_malloc:wrapper.chain.chainType];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ - (DSAuthenticationKeysDerivationPath *)identityECDSAKeysDerivationPathForWallet
[mArray addObject:fundsDerivationPath];
}
}
if (account.coinJoinDerivationPath && ![account.coinJoinDerivationPath hasExtendedPublicKey])
[mArray addObject:account.coinJoinDerivationPath];
}

return [mArray copy];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ - (NSArray *)registerAddressesWithSettings:(DSGapLimit *)settings
inContext:(NSManagedObjectContext *)context {
DSGapLimitFunds *gapLimitSettings = (DSGapLimitFunds *)settings;
uintptr_t gapLimit = gapLimitSettings.gapLimit;
BOOL internal = (gapLimitSettings.direction & DSGapLimitFundsDirection_Internal) == DSGapLimitFundsDirection_Internal;
BOOL internal = FLAG_IS_SET(gapLimitSettings.direction, DSGapLimitFundsDirection_Internal);
if (!self.account.wallet.isTransient) {
NSAssert(self.addressesLoaded, @"addresses must be loaded before calling this function");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN

- (NSDictionary<NSData *, NSNumber *> *)friendsWithActivityForType:(DSDashpayUserEntityFriendActivityType)activityType count:(NSUInteger)count ascending:(BOOL)ascending;

- (NSError *)applyTransientDashpayUser:(DSTransientDashpayUser *)transientDashpayUser
- (NSError *)applyTransientDashpayUser:(DTransientUser *)transientDashpayUser
save:(BOOL)save;

- (void)sendAmount:(uint64_t)amount fromAccount:(DSAccount *)account toFriendWithIdentityIdentifier:(UInt256)identityIdentifier requestingAdditionalInfo:(DSTransactionCreationRequestingAdditionalInfoBlock)additionalInfoRequest
Expand Down
21 changes: 11 additions & 10 deletions DashSync/shared/Models/Entities/DSDashpayUserEntity+CoreDataClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,21 @@ - (NSString *)username {
return username.stringValue;
}

- (NSError *)applyTransientDashpayUser:(DSTransientDashpayUser *)transientDashpayUser save:(BOOL)save {
- (NSError *)applyTransientDashpayUser:(DTransientUser *)transientDashpayUser save:(BOOL)save {
if (!self.documentIdentifier) {
self.documentIdentifier = transientDashpayUser.documentIdentifier;
self.documentIdentifier = NSDataFromPtr(transientDashpayUser->document_identifier->_0->_0);
} else if (self.documentIdentifier) {
return [NSError errorWithCode:500 localizedDescriptionKey:@"Error when updating profile information"];
}
self.localProfileDocumentRevision = transientDashpayUser.revision;
self.remoteProfileDocumentRevision = transientDashpayUser.revision;
self.avatarPath = transientDashpayUser.avatarPath;
self.publicMessage = transientDashpayUser.publicMessage;
self.displayName = transientDashpayUser.displayName;

self.createdAt = transientDashpayUser.createdAt;
self.updatedAt = transientDashpayUser.updatedAt;
dpp_prelude_Revision *revision = transientDashpayUser->revision;
self.localProfileDocumentRevision = revision->_0;
self.remoteProfileDocumentRevision = revision->_0;
self.avatarPath = NSStringFromPtr(transientDashpayUser->avatar_url);
self.publicMessage = NSStringFromPtr(transientDashpayUser->public_message);
self.displayName = NSStringFromPtr(transientDashpayUser->display_name);

self.createdAt = transientDashpayUser->created_at->_0;
self.updatedAt = transientDashpayUser->updated_at->_0;

if (save) {
[self.managedObjectContext ds_save];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nullable, nonatomic, retain) NSData *signature;
@property (nullable, nonatomic, retain) NSData *cycleHash;
@property (assign, nonatomic) uint8_t version;
@property (assign, nonatomic) uint16_t version;
@property (assign, nonatomic) BOOL validSignature;
@property (nullable, nonatomic, retain) DSTransactionEntity *transaction;

Expand Down
Loading
Loading