From 735ed87b7846b9e85bb2b189858132ae0de7f3bf Mon Sep 17 00:00:00 2001 From: natsoni Date: Sun, 13 Oct 2024 11:14:23 +0900 Subject: [PATCH] Route submitpackage calls to core on esplora backends --- backend/src/api/bitcoin/bitcoin.routes.ts | 7 ++++--- frontend/src/app/services/api.service.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/api/bitcoin/bitcoin.routes.ts b/backend/src/api/bitcoin/bitcoin.routes.ts index 14e5e197d..3b33c1ead 100644 --- a/backend/src/api/bitcoin/bitcoin.routes.ts +++ b/backend/src/api/bitcoin/bitcoin.routes.ts @@ -48,6 +48,8 @@ class BitcoinRoutes { .post(config.MEMPOOL.API_URL_PREFIX + 'psbt/addparents', this.postPsbtCompletion) .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-bulk/:from', this.getBlocksByBulk.bind(this)) .get(config.MEMPOOL.API_URL_PREFIX + 'blocks-bulk/:from/:to', this.getBlocksByBulk.bind(this)) + // Temporarily add txs/package endpoint for all backends until esplora supports it + .post(config.MEMPOOL.API_URL_PREFIX + 'txs/package', this.$submitPackage) ; if (config.MEMPOOL.BACKEND !== 'esplora') { @@ -58,7 +60,6 @@ class BitcoinRoutes { .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId', this.getTransaction) .post(config.MEMPOOL.API_URL_PREFIX + 'tx', this.$postTransaction) .post(config.MEMPOOL.API_URL_PREFIX + 'txs/test', this.$testTransactions) - .post(config.MEMPOOL.API_URL_PREFIX + 'txs/package', this.$submitPackage) .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/hex', this.getRawTransaction) .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/status', this.getTransactionStatus) .get(config.MEMPOOL.API_URL_PREFIX + 'tx/:txId/outspends', this.getTransactionOutspends) @@ -799,8 +800,8 @@ class BitcoinRoutes { try { const rawTxs = Common.getTransactionsFromRequest(req); const maxfeerate = parseFloat(req.query.maxfeerate as string); - const maxburneamount = parseFloat(req.query.maxburneamount as string); - const result = await bitcoinApi.$submitPackage(rawTxs, maxfeerate, maxburneamount); + const maxburnamount = parseFloat(req.query.maxburnamount as string); + const result = await bitcoinClient.submitPackage(rawTxs, maxfeerate ?? undefined, maxburnamount ?? undefined); res.send(result); } catch (e: any) { handleError(req, res, 400, e.message && e.code ? 'submitpackage RPC error: ' + JSON.stringify({ code: e.code, message: e.message }) diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index c536c0bb4..c58a67f0e 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -255,7 +255,7 @@ export class ApiService { if (maxburnamount) { queryParams.push(`maxburnamount=${maxburnamount}`); } - return this.httpClient.post(this.apiBaseUrl + this.apiBasePath + '/api/txs/package' + (queryParams.length > 0 ? `?${queryParams.join('&')}` : ''), rawTxs); + return this.httpClient.post(this.apiBaseUrl + this.apiBasePath + '/api/v1/txs/package' + (queryParams.length > 0 ? `?${queryParams.join('&')}` : ''), rawTxs); } getTransactionStatus$(txid: string): Observable {