fix: mempool hostname

This commit is contained in:
Vlad Stan 2022-11-24 17:20:12 +02:00
parent 00ba09d201
commit d3c3622d22
2 changed files with 20 additions and 10 deletions

View file

@ -218,7 +218,7 @@
<div class="col text-center">
<a
style="color: unset"
:href="mempool_endpoint + '/address/' + charge.onchainaddress"
:href="mempoolEndpoint + '/address/' + charge.onchainaddress"
target="_blank"
><span
class="text-subtitle1"
@ -303,7 +303,8 @@
data() {
return {
charge: JSON.parse('{{charge_data | tojson}}'),
mempool_endpoint: '{{mempool_endpoint}}',
mempoolEndpoint: '{{mempool_endpoint}}',
network: '{{network}}',
pendingFunds: 0,
ws: null,
newProgress: 0.4,
@ -316,6 +317,15 @@
cancelListener: () => {}
}
},
computed: {
mempoolHostname: function () {
let hostname = new URL(this.mempoolEndpoint).hostname
if (this.network === 'Testnet') {
hostname += '/testnet'
}
return hostname
}
},
methods: {
checkBalances: async function () {
if (this.charge.hasStaleBalance) return
@ -335,7 +345,7 @@
const {
bitcoin: {addresses: addressesAPI}
} = mempoolJS({
hostname: new URL(this.mempool_endpoint).hostname
hostname: new URL(this.mempoolEndpoint).hostname
})
try {
@ -378,10 +388,10 @@
const {
bitcoin: {websocket}
} = mempoolJS({
hostname: new URL(this.mempool_endpoint).hostname
hostname: new URL(this.mempoolEndpoint).hostname
})
this.ws = new WebSocket('wss://mempool.space/api/v1/ws')
this.ws = new WebSocket(`wss://${this.mempoolHostname}/api/v1/ws`)
this.ws.addEventListener('open', x => {
if (this.charge.onchainaddress) {
this.trackAddress(this.charge.onchainaddress)

View file

@ -30,17 +30,17 @@ async def display(request: Request, charge_id: str):
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Charge link does not exist."
)
wallet = await get_wallet(charge.lnbitswallet)
onchainwallet_config = await get_charge_config(charge_id)
inkey = wallet.inkey if wallet else None
mempool_endpoint = (
onchainwallet_config.mempool_endpoint if onchainwallet_config else None
)
if onchainwallet_config:
mempool_endpoint = onchainwallet_config.mempool_endpoint
network = onchainwallet_config.network
return satspay_renderer().TemplateResponse(
"satspay/display.html",
{
"request": request,
"charge_data": charge.dict(),
"mempool_endpoint": mempool_endpoint,
"network": network,
},
)