Skip to content

Commit

Permalink
fix: emit invoice.paid event only if request succeeded (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 authored Jan 26, 2019
1 parent 947bcbc commit 5b41412
Show file tree
Hide file tree
Showing 2 changed files with 218 additions and 811 deletions.
8 changes: 5 additions & 3 deletions lib/lightning/LndClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,13 @@ class LndClient extends BaseClient implements LightningClient {
const request = new lndrpc.SendRequest();
request.setPaymentRequest(invoice);

const repsonse = this.unaryCall<lndrpc.SendRequest, lndrpc.SendResponse.AsObject>('sendPaymentSync', request);
const response = await this.unaryCall<lndrpc.SendRequest, lndrpc.SendResponse.AsObject>('sendPaymentSync', request);

this.emit('invoice.paid', invoice);
if (response.paymentError === '') {
this.emit('invoice.paid', invoice);
}

return repsonse;
return response;
}

/**
Expand Down
Loading

0 comments on commit 5b41412

Please sign in to comment.