Skip to content

Commit

Permalink
feat(swaps): log when sending payments
Browse files Browse the repository at this point in the history
  • Loading branch information
sangaman committed Jun 9, 2020
1 parent 55876ae commit 46e2d4e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/connextclient/ConnextClient.ts
Expand Up @@ -587,6 +587,7 @@ class ConnextClient extends SwapClient {
* @param lockHash
*/
private executeHashLockTransfer = async (payload: TokenPaymentRequest): Promise<string> => {
this.logger.debug(`sending payment of ${payload.amount} with hash ${payload.lockHash} to ${payload.recipient}`);
const res = await this.sendRequest('/hashlock-transfer', 'POST', payload);
const { appId } = await parseResponseBody<ConnextTransferResponse>(res);
return appId;
Expand Down
5 changes: 2 additions & 3 deletions lib/lndclient/LndClient.ts
Expand Up @@ -595,7 +595,7 @@ class LndClient extends SwapClient {
* Sends a payment through the Lightning Network.
*/
private sendPaymentSync = (request: lndrpc.SendRequest): Promise<lndrpc.SendResponse> => {
this.logger.trace(`sending payment of ${request.getAmt()} for ${request.getPaymentHashString()}`);
this.logger.trace(`sending payment with request: ${JSON.stringify(request.toObject())}`);
return this.unaryCall<lndrpc.SendRequest, lndrpc.SendResponse>('sendPaymentSync', request);
}

Expand Down Expand Up @@ -631,8 +631,7 @@ class LndClient extends SwapClient {
if (!this.isConnected()) {
throw swapErrors.FINAL_PAYMENT_ERROR(errors.UNAVAILABLE(this.currency, this.status).message);
}

this.logger.trace(`sending payment with ${JSON.stringify(request.toObject())}`);
this.logger.debug(`sending payment of ${request.getAmt()} with hash ${request.getPaymentHashString()} to ${request.getDestString()}`);
let sendPaymentResponse: lndrpc.SendResponse;
try {
sendPaymentResponse = await this.sendPaymentSync(request);
Expand Down
1 change: 1 addition & 0 deletions lib/swaps/Swaps.ts
Expand Up @@ -1187,6 +1187,7 @@ class Swaps extends EventEmitter {
case SwapPhase.SwapAccepted:
assert(deal.role === SwapRole.Maker, 'SwapAccepted can only be set by the maker');
assert(deal.phase === SwapPhase.SwapCreated, 'SwapAccepted can be only be set after SwapCreated');
this.logger.debug(`Setting SwapAccepted phase for deal ${deal.rHash}`);
break;
case SwapPhase.SendingPayment:
assert(deal.role === SwapRole.Taker && deal.phase === SwapPhase.SwapRequested ||
Expand Down

0 comments on commit 46e2d4e

Please sign in to comment.