Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "secp256k1"]
path = secp256k1
url = https://github.com/bitcoin/secp256k1.git
646 changes: 103 additions & 543 deletions DashWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -64,9 +63,8 @@
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
language = ""
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
37 changes: 0 additions & 37 deletions DashWallet/BRAddressEntity.h

This file was deleted.

37 changes: 0 additions & 37 deletions DashWallet/BRAddressEntity.m

This file was deleted.

75 changes: 41 additions & 34 deletions DashWallet/BRAmountViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#import <DashSync/DashSync.h>

#import "BRAppDelegate.h"
#import "BRAmountViewController.h"
#import "BRPaymentRequest.h"
#import "BRWalletManager.h"
#import "BRPeerManager.h"
#import "BRTransaction.h"
#import "BREventManager.h"
#import "NSString+Dash.h"
#import "BRBubbleView.h"

@interface BRAmountViewController ()
Expand Down Expand Up @@ -59,7 +56,7 @@ - (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view.

BRWalletManager *manager = [BRWalletManager sharedInstance];
DSPriceManager *manager = [DSPriceManager sharedInstance];
NSMutableCharacterSet *charset = [NSMutableCharacterSet decimalDigitCharacterSet];

[charset addCharactersInString:manager.dashFormat.currencyDecimalSeparator];
Expand Down Expand Up @@ -121,9 +118,11 @@ - (void)viewWillAppear:(BOOL)animated
}
self.wallpaper.hidden = NO;

DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance];

if (self.navigationController.viewControllers.firstObject != self) {
self.navigationItem.leftBarButtonItem = nil;
if ([[BRWalletManager sharedInstance] didAuthenticate]) [self unlock:nil];
if (authManager.didAuthenticate) [self unlock:nil];
self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
}
else {
Expand All @@ -133,11 +132,13 @@ - (void)viewWillAppear:(BOOL)animated
self.navigationController.navigationBar.barStyle = UIStatusBarStyleDefault;
}

DSChainPeerManager *peerManager = [BRAppDelegate sharedDelegate].peerManager;

self.balanceObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:BRWalletBalanceChangedNotification object:nil queue:nil
[[NSNotificationCenter defaultCenter] addObserverForName:DSWalletBalanceDidChangeNotification object:nil queue:nil
usingBlock:^(NSNotification *note) {
if ([BRPeerManager sharedInstance].syncProgress < 1.0) return; // wait for sync before updating balance
if ([[BRWalletManager sharedInstance] didAuthenticate]) {
if (peerManager.syncProgress < 1.0) return; // wait for sync before updating balance
if (authManager.didAuthenticate) {
[self updateTitleView];
}
}];
Expand All @@ -163,7 +164,7 @@ - (void)viewWillDisappear:(BOOL)animated

- (void)updateLocalCurrencyLabel
{
BRWalletManager *manager = [BRWalletManager sharedInstance];
DSPriceManager *manager = [DSPriceManager sharedInstance];
uint64_t amount;
if (self.usingShapeshift) {
amount = (self.swapped) ? [manager amountForBitcoinCurrencyString:self.amountLabel.text] * 1.02:
Expand Down Expand Up @@ -204,24 +205,28 @@ - (void)updateLocalCurrencyLabel
}

-(UILabel*)titleLabel {
BRWalletManager *manager = [BRWalletManager sharedInstance];
DSPriceManager *manager = [DSPriceManager sharedInstance];
UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 200)];
titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
[titleLabel setBackgroundColor:[UIColor clearColor]];
NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy];
DSChain *chain = [BRAppDelegate sharedDelegate].chain;
DSWallet *wallet = chain.wallets.firstObject;
NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor] useSignificantDigits:TRUE] mutableCopy];
NSString * titleString = [NSString stringWithFormat:@" (%@)",
[manager localCurrencyStringForDashAmount:manager.wallet.balance]];
[manager localCurrencyStringForDashAmount:wallet.balance]];
[attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]];
titleLabel.attributedText = attributedDashString;
return titleLabel;
}

-(void)updateTitleView {
if (self.navigationItem.titleView && [self.navigationItem.titleView isKindOfClass:[UILabel class]]) {
BRWalletManager *manager = [BRWalletManager sharedInstance];
NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:manager.wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy];
DSPriceManager *manager = [DSPriceManager sharedInstance];
DSChain *chain = [BRAppDelegate sharedDelegate].chain;
DSWallet *wallet = chain.wallets.firstObject;
NSMutableAttributedString * attributedDashString = [[manager attributedStringForDashAmount:wallet.balance withTintColor:[UIColor whiteColor]] mutableCopy];
NSString * titleString = [NSString stringWithFormat:@" (%@)",
[manager localCurrencyStringForDashAmount:manager.wallet.balance]];
[manager localCurrencyStringForDashAmount:wallet.balance]];
[attributedDashString appendAttributedString:[[NSAttributedString alloc] initWithString:titleString attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}]];
((UILabel*)self.navigationItem.titleView).attributedText = attributedDashString;
[((UILabel*)self.navigationItem.titleView) sizeToFit];
Expand All @@ -238,13 +243,13 @@ - (IBAction)unlock:(id)sender
[self.tipView popOut];
self.tipView = nil;
}
BRWalletManager *manager = [BRWalletManager sharedInstance];
[BREventManager saveEvent:@"amount:unlock"];
DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance];
[DSEventManager saveEvent:@"amount:unlock"];

if (sender && ! manager.didAuthenticate) {
[manager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) {
if (sender && ! authManager.didAuthenticate) {
[authManager authenticateWithPrompt:nil andTouchId:YES alertIfLockout:YES completion:^(BOOL authenticated,BOOL cancelled) {
if (authenticated) {
[BREventManager saveEvent:@"amount:successful_unlock"];
[DSEventManager saveEvent:@"amount:successful_unlock"];

[self updateTitleView];
[self.navigationItem setRightBarButtonItem:self.payButton animated:(sender) ? YES : NO];
Expand Down Expand Up @@ -286,18 +291,18 @@ - (IBAction)pay:(id)sender
[self.tipView popOut];
self.tipView = nil;
}
BRWalletManager *manager = [BRWalletManager sharedInstance];
DSPriceManager *manager = [DSPriceManager sharedInstance];
if (self.usingShapeshift) {

self.amount = (self.swapped) ? [manager amountForBitcoinString:self.amountLabel.text]:
[manager amountForDashString:self.amountLabel.text];

if (self.amount == 0){
[BREventManager saveEvent:@"amount:pay_zero"];
[DSEventManager saveEvent:@"amount:pay_zero"];
return;
}

[BREventManager saveEvent:@"amount:pay_using_shapeshift"];
[DSEventManager saveEvent:@"amount:pay_using_shapeshift"];

if (self.swapped) {
[self.delegate amountViewController:self shapeshiftBitcoinAmount:self.amount approximateDashAmount:self.amount/manager.bitcoinDashPrice.doubleValue];
Expand All @@ -308,26 +313,26 @@ - (IBAction)pay:(id)sender
[manager amountForDashString:self.amountLabel.text];

if (self.amount == 0){
[BREventManager saveEvent:@"amount:pay_zero"];
[DSEventManager saveEvent:@"amount:pay_zero"];
return;
}

[BREventManager saveEvent:@"amount:pay"];
[DSEventManager saveEvent:@"amount:pay"];

[self.delegate amountViewController:self selectedAmount:self.amount];
}
}

- (IBAction)done:(id)sender
{
[BREventManager saveEvent:@"amount:dismiss"];
[DSEventManager saveEvent:@"amount:dismiss"];
[self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)swapCurrency:(id)sender
{
self.swapped = ! self.swapped;
[BREventManager saveEvent:@"amount:swap_currency"];
[DSEventManager saveEvent:@"amount:swap_currency"];

if (self.swapLeftLabel.hidden) {
self.swapLeftLabel.text = self.localCurrencyLabel.text;
Expand All @@ -350,7 +355,7 @@ - (IBAction)swapCurrency:(id)sender
}

CGFloat scale = self.swapRightLabel.font.pointSize/self.swapLeftLabel.font.pointSize;
BRWalletManager *manager = [BRWalletManager sharedInstance];
DSPriceManager *manager = [DSPriceManager sharedInstance];
NSString *s = (self.swapped) ? self.localCurrencyLabel.text : self.amountLabel.text;
uint64_t amount =
[manager amountForLocalCurrencyString:(self.swapped) ? [s substringWithRange:NSMakeRange(1, s.length - 2)] : s];
Expand Down Expand Up @@ -422,7 +427,7 @@ - (IBAction)swapCurrency:(id)sender

- (IBAction)releaseSwapButton:(id)sender
{
[BREventManager saveEvent:@"amount:release_swap"];
[DSEventManager saveEvent:@"amount:release_swap"];
[UIView animateWithDuration:0.1 animations:^{
//self.swapLeftLabel.transform = CGAffineTransformIdentity;
self.swapLeftLabel.textColor = self.localCurrencyLabel.textColor;
Expand Down Expand Up @@ -453,7 +458,7 @@ -(IBAction)clickedBottomBar:(id)sender
-(void)updateAmountLabel:(UILabel *)amountLabel shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
{
BRWalletManager *m = [BRWalletManager sharedInstance];
DSPriceManager *m = [DSPriceManager sharedInstance];
NSNumberFormatter *formatter;
if (self.usingShapeshift) {
formatter = (self.swapped) ? m.bitcoinFormat:m.dashFormat;
Expand Down Expand Up @@ -578,8 +583,10 @@ -(void)updateAmountLabel:(UILabel *)amountLabel shouldChangeCharactersInRange:(N
}
}

DSAuthenticationManager *authManager = [DSAuthenticationManager sharedInstance];

if (self.navigationController.viewControllers.firstObject != self) {
if (! m.didAuthenticate && (formattedAmount.length == 0 || self.amountLabelIsEmpty || ![number floatValue]) && self.navigationItem.rightBarButtonItem != self.lock) {
if (! authManager.didAuthenticate && (formattedAmount.length == 0 || self.amountLabelIsEmpty || ![number floatValue]) && self.navigationItem.rightBarButtonItem != self.lock) {
[self.navigationItem setRightBarButtonItem:self.lock animated:YES];
}
else if ((formattedAmount.length > 0 && !self.amountLabelIsEmpty && [number floatValue]) && self.navigationItem.rightBarButtonItem != self.payButton) {
Expand Down
8 changes: 8 additions & 0 deletions DashWallet/BRAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@
#define BRURLNotification @"BRURLNotification"
#define BRFileNotification @"BRFileNotification"

@class DSChain;
@class DSChainPeerManager;

@interface BRAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (readonly, strong, nonatomic) DSChain *chain;
@property (readonly, strong, nonatomic) DSChainPeerManager *peerManager;

+ (instancetype)sharedDelegate;

- (void)registerForPushNotifications;

@end
Loading