Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
[#253] added logs for payment loading/sending
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed May 14, 2014
1 parent 328a1be commit 05e2f48
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Hive/Backend/HIBitcoinURIService.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");

Expand Down
10 changes: 10 additions & 0 deletions Hive/Controllers/HISendBitcoinsWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ - (void)usePaymentRequestTitle {
}

- (void)showPaymentRequest:(int)sessionId details:(NSDictionary *)data {
HILogDebug(@"Payment request data loaded: %@", data);

_paymentRequestSession = sessionId;
[self usePaymentRequestTitle];

Expand Down Expand Up @@ -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];
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions Hive/HIAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 05e2f48

Please sign in to comment.