Skip to content

Commit fd8ec28

Browse files
chore(abstract-lightning): dont include coin in path
BTC-0 TICKET: BTC-0
1 parent b7863d8 commit fd8ec28

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export class LightningWallet implements ILightningWallet {
176176

177177
async createInvoice(params: CreateInvoiceBody): Promise<Invoice> {
178178
const createInvoiceResponse = await this.wallet.bitgo
179-
.post(this.wallet.baseCoin.url(`/wallet/${this.wallet.id()}/lightning/invoice`))
179+
.post(this.wallet.bitgo.url(`/wallet/${this.wallet.id()}/lightning/invoice`, 2))
180180
.send(t.exact(CreateInvoiceBody).encode(params))
181181
.result();
182182
return sdkcore.decodeOrElse(Invoice.name, Invoice, createInvoiceResponse, (error) => {
@@ -187,7 +187,7 @@ export class LightningWallet implements ILightningWallet {
187187

188188
async getInvoice(paymentHash: string): Promise<InvoiceInfo> {
189189
const response = await this.wallet.bitgo
190-
.get(this.wallet.baseCoin.url(`/wallet/${this.wallet.id()}/lightning/invoice/${paymentHash}`))
190+
.get(this.wallet.bitgo.url(`/wallet/${this.wallet.id()}/lightning/invoice/${paymentHash}`, 2))
191191
.result();
192192
return decodeOrElse(InvoiceInfo.name, InvoiceInfo, response, (error) => {
193193
throw new Error(`Invalid get invoice response ${error}`);
@@ -197,7 +197,7 @@ export class LightningWallet implements ILightningWallet {
197197
async listInvoices(params: InvoiceQuery): Promise<InvoiceInfo[]> {
198198
const returnCodec = t.array(InvoiceInfo);
199199
const createInvoiceResponse = await this.wallet.bitgo
200-
.get(this.wallet.baseCoin.url(`/wallet/${this.wallet.id()}/lightning/invoice`))
200+
.get(this.wallet.bitgo.url(`/wallet/${this.wallet.id()}/lightning/invoice`, 2))
201201
.query(InvoiceQuery.encode(params))
202202
.result();
203203
return sdkcore.decodeOrElse(returnCodec.name, returnCodec, createInvoiceResponse, (error) => {
@@ -264,7 +264,7 @@ export class LightningWallet implements ILightningWallet {
264264

265265
async getPayment(paymentHash: string): Promise<PaymentInfo> {
266266
const response = await this.wallet.bitgo
267-
.get(this.wallet.baseCoin.url(`/wallet/${this.wallet.id()}/lightning/payment/${paymentHash}`))
267+
.get(this.wallet.bitgo.url(`/wallet/${this.wallet.id()}/lightning/payment/${paymentHash}`, 2))
268268
.result();
269269
return decodeOrElse(PaymentInfo.name, PaymentInfo, response, (error) => {
270270
throw new Error(`Invalid payment response: ${error}`);
@@ -273,7 +273,7 @@ export class LightningWallet implements ILightningWallet {
273273

274274
async listPayments(params: PaymentQuery): Promise<PaymentInfo[]> {
275275
const response = await this.wallet.bitgo
276-
.get(this.wallet.baseCoin.url(`/wallet/${this.wallet.id()}/lightning/payment`))
276+
.get(this.wallet.bitgo.url(`/wallet/${this.wallet.id()}/lightning/payment`, 2))
277277
.query(PaymentQuery.encode(params))
278278
.result();
279279
return decodeOrElse(t.array(PaymentInfo).name, t.array(PaymentInfo), response, (error) => {
@@ -283,7 +283,7 @@ export class LightningWallet implements ILightningWallet {
283283

284284
async getTransaction(txId: string): Promise<Transaction> {
285285
const response = await this.wallet.bitgo
286-
.get(this.wallet.baseCoin.url(`/wallet/${this.wallet.id()}/lightning/transaction/${txId}`))
286+
.get(this.wallet.bitgo.url(`/wallet/${this.wallet.id()}/lightning/transaction/${txId}`, 2))
287287
.result();
288288
return decodeOrElse(Transaction.name, Transaction, response, (error) => {
289289
throw new Error(`Invalid transaction response: ${error}`);
@@ -292,7 +292,7 @@ export class LightningWallet implements ILightningWallet {
292292

293293
async listTransactions(params: TransactionQuery): Promise<Transaction[]> {
294294
const response = await this.wallet.bitgo
295-
.get(this.wallet.baseCoin.url(`/wallet/${this.wallet.id()}/lightning/transaction`))
295+
.get(this.wallet.bitgo.url(`/wallet/${this.wallet.id()}/lightning/transaction`, 2))
296296
.query(TransactionQuery.encode(params))
297297
.result();
298298
return decodeOrElse(t.array(Transaction).name, t.array(Transaction), response, (error) => {

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,13 @@ describe('Lightning wallets', function () {
262262
createdAt: new Date(),
263263
updatedAt: new Date(),
264264
};
265-
const query = { status: 'open', startDate: new Date(), limit: 100n } as InvoiceQuery;
265+
const query = {
266+
status: 'open',
267+
startDate: new Date(),
268+
limit: 100n,
269+
} as InvoiceQuery;
266270
const listInvoicesNock = nock(bgUrl)
267-
.get(`/api/v2/${coinName}/wallet/${wallet.wallet.id()}/lightning/invoice`)
271+
.get(`/api/v2/wallet/${wallet.wallet.id()}/lightning/invoice`)
268272
.query(InvoiceQuery.encode(query))
269273
.reply(200, [InvoiceInfo.encode(invoice)]);
270274
const invoiceResponse = await wallet.listInvoices(query);
@@ -275,7 +279,7 @@ describe('Lightning wallets', function () {
275279

276280
it('listInvoices should throw error if wp response is invalid', async function () {
277281
const listInvoicesNock = nock(bgUrl)
278-
.get(`/api/v2/${coinName}/wallet/${wallet.wallet.id()}/lightning/invoice`)
282+
.get(`/api/v2/wallet/${wallet.wallet.id()}/lightning/invoice`)
279283
.reply(200, [{ valueMsat: '1000' }]);
280284
await assert.rejects(async () => await wallet.listInvoices({}), /Invalid list invoices response/);
281285
listInvoicesNock.done();
@@ -296,10 +300,7 @@ describe('Lightning wallets', function () {
296300
valueMsat: 1000n,
297301
};
298302
const createInvoiceNock = nock(bgUrl)
299-
.post(
300-
`/api/v2/${coinName}/wallet/${wallet.wallet.id()}/lightning/invoice`,
301-
CreateInvoiceBody.encode(createInvoice)
302-
)
303+
.post(`/api/v2/wallet/${wallet.wallet.id()}/lightning/invoice`, CreateInvoiceBody.encode(createInvoice))
303304
.reply(200, Invoice.encode(invoice));
304305
const createInvoiceResponse = await wallet.createInvoice(createInvoice);
305306
assert.deepStrictEqual(createInvoiceResponse, invoice);
@@ -313,7 +314,7 @@ describe('Lightning wallets', function () {
313314
expiry: 100,
314315
};
315316
const createInvoiceNock = nock(bgUrl)
316-
.post(`/api/v2/${coinName}/wallet/${wallet.wallet.id()}/lightning/invoice`)
317+
.post(`/api/v2/wallet/${wallet.wallet.id()}/lightning/invoice`)
317318
.reply(200, { valueMsat: '1000' });
318319
await assert.rejects(async () => await wallet.createInvoice(createInvoice), /Invalid create invoice response/);
319320
createInvoiceNock.done();

0 commit comments

Comments
 (0)