Skip to content

Commit 1f4cf69

Browse files
Merge pull request #5769 from BitGo/BTC-0-get-transfer
feat(abstract-lightning): get transfer for lightning pay invoice
2 parents d6a052f + cfc6127 commit 1f4cf69

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

modules/abstract-lightning/src/wallet/lightning.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type PayInvoiceResponse = {
3333
pendingApproval?: PendingApprovalData;
3434
// Absent if there's a pending approval
3535
paymentStatus?: LndCreatePaymentResponse;
36+
transfer?: any;
3637
};
3738

3839
/**
@@ -254,13 +255,17 @@ export class LightningWallet implements ILightningWallet {
254255
);
255256

256257
const coinSpecific = transactionRequestSend.transactions?.[0]?.unsignedTx?.coinSpecific;
257-
258+
let transfer;
259+
if (coinSpecific && coinSpecific.paymentHash && typeof coinSpecific.paymentHash === 'string') {
260+
transfer = await this.wallet.getTransfer({ id: coinSpecific.paymentHash });
261+
}
258262
return {
259263
txRequestId: transactionRequestCreate.txRequestId,
260264
txRequestState: transactionRequestSend.state,
261265
paymentStatus: coinSpecific
262266
? t.exact(LndCreatePaymentResponse).encode(coinSpecific as LndCreatePaymentResponse)
263267
: undefined,
268+
transfer,
264269
};
265270
}
266271

modules/bitgo/test/v2/unit/lightning/lightningWallets.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,17 @@ describe('Lightning wallets', function () {
358358
],
359359
};
360360

361+
const transferData = {
362+
id: 'fake_id',
363+
coin: 'tlnbtc',
364+
state: 'confirmed',
365+
txid: lndResponse.paymentHash,
366+
};
367+
368+
const getTransferNock = nock(bgUrl)
369+
.get(`/api/v2/${coinName}/wallet/${wallet.wallet.id()}/transfer/${lndResponse.paymentHash}`)
370+
.reply(200, transferData);
371+
361372
const createTxRequestNock = nock(bgUrl)
362373
.post(`/api/v2/wallet/${wallet.wallet.id()}/txrequests`)
363374
.reply(200, txRequestResponse);
@@ -398,6 +409,7 @@ describe('Lightning wallets', function () {
398409
finalPaymentResponse.transactions[0].unsignedTx.coinSpecific.paymentPreimage
399410
);
400411

412+
getTransferNock.done();
401413
createTxRequestNock.done();
402414
sendTxRequestNock.done();
403415
userAuthKeyNock.done();

0 commit comments

Comments
 (0)