From 05e2f485086b294a065a5407f7cf488e274823b8 Mon Sep 17 00:00:00 2001 From: Jakub Suder Date: Wed, 14 May 2014 15:39:16 +0200 Subject: [PATCH] [#253] added logs for payment loading/sending --- Hive/Backend/HIBitcoinURIService.m | 4 ++++ Hive/Controllers/HISendBitcoinsWindowController.m | 10 ++++++++++ Hive/HIAppDelegate.m | 2 ++ 3 files changed, 16 insertions(+) diff --git a/Hive/Backend/HIBitcoinURIService.m b/Hive/Backend/HIBitcoinURIService.m index de6e0169..601f3c0b 100644 --- a/Hive/Backend/HIBitcoinURIService.m +++ b/Hive/Backend/HIBitcoinURIService.m @@ -55,6 +55,8 @@ - (BOOL)handlePaymentRequestURL:(NSString *)URLString fromBitcoinURI:(HIBitcoinU __block HISendBitcoinsWindowController *window; + HILogDebug(@"Loading remote payment request from %@", URLString); + [manager openPaymentRequestFromURL:URLString error:&callError callback:^(NSError *loadError, int sessionId, NSDictionary *data) { @@ -89,6 +91,8 @@ - (BOOL)handlePaymentRequestURL:(NSString *)URLString fromBitcoinURI:(HIBitcoinU } - (void)handlePaymentRequestURLErrorForURL:(NSString *)URLString { + HILogWarn(@"Payment request URL is invalid: %@", URLString); + NSString *title = NSLocalizedString(@"This payment request link is invalid.", @"Alert title when URL to a payment request file is not valid"); diff --git a/Hive/Controllers/HISendBitcoinsWindowController.m b/Hive/Controllers/HISendBitcoinsWindowController.m index 7a520164..8e582a8b 100644 --- a/Hive/Controllers/HISendBitcoinsWindowController.m +++ b/Hive/Controllers/HISendBitcoinsWindowController.m @@ -291,6 +291,8 @@ - (void)usePaymentRequestTitle { } - (void)showPaymentRequest:(int)sessionId details:(NSDictionary *)data { + HILogDebug(@"Payment request data loaded: %@", data); + _paymentRequestSession = sessionId; [self usePaymentRequestTitle]; @@ -694,6 +696,8 @@ - (void)sendBitcoin:(uint64)satoshi toTarget:(NSString *)target password:(HIPass - (void)sendPaymentRequest:(int)sessionId password:(HIPasswordHolder *)password { void (^callback)(NSError*, NSDictionary*) = ^(NSError *sendError, NSDictionary *data) { if (sendError) { + HILogWarn(@"Payment sending failed: %@", sendError); + [self.sendButton hideSpinner]; [self.cancelButton setEnabled:YES]; [self showPaymentSendErrorAlert]; @@ -704,12 +708,16 @@ - (void)sendPaymentRequest:(int)sessionId password:(HIPasswordHolder *)password NSError *callError = nil; + HILogDebug(@"Submitting payment request..."); + [[HIBitcoinManager defaultManager] sendPaymentRequest:sessionId password:password.data error:&callError callback:callback]; if (callError) { + HILogWarn(@"Payment could not be sent: %@", callError); + if (callError.code == kHIBitcoinManagerWrongPassword) { [self.window hiShake]; } else if (callError.code == kHIBitcoinManagerSendingDustError) { @@ -741,6 +749,8 @@ - (void)closeAndNotifyWithSuccess:(BOOL)success transactionId:(NSString *)transa } - (void)showPaymentConfirmation:(NSDictionary *)data { + HILogDebug(@"Payment confirmed: %@", data); + NSString *memo = data[@"memo"]; if (memo.length > 0) { diff --git a/Hive/HIAppDelegate.m b/Hive/HIAppDelegate.m index 15ad1e71..6cad03bd 100644 --- a/Hive/HIAppDelegate.m +++ b/Hive/HIAppDelegate.m @@ -506,6 +506,8 @@ - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename { HIBitcoinManager *manager = [HIBitcoinManager defaultManager]; NSError *callError = nil; + HILogDebug(@"Opening local payment request file from %@", filename); + [manager openPaymentRequestFromFile:filename error:&callError callback:^(NSError *loadError, int sessionId, NSDictionary *data) {