Sent Data:
@@ -292,8 +306,10 @@
nostrrelayLinks: [],
filter: '',
testData: {
+ show: false,
wsConnection: null,
senderPrivateKey: null,
+ senderPublicKey: null,
recieverPublicKey: null,
message: null,
sentData: '',
@@ -405,6 +421,38 @@
LNbits.utils.notifyApiError(error)
})
},
+ toggleTestPanel: async function() {
+ if (this.testData.show) {
+ await this.hideTestPannel()
+ } else {
+ await this.showTestPanel()
+ }
+ },
+ showTestPanel: async function() {
+ this.testData = {
+ show: true,
+ wsConnection: null,
+ senderPrivateKey: this.$q.localStorage.getItem('lnbits.nostrclient.senderPrivateKey') || '',
+ recieverPublicKey: null,
+ message: null,
+ sentData: '',
+ receivedData: ''
+ }
+ await this.closeWebsocket()
+ this.connectToWebsocket()
+ },
+ hideTestPannel: async function() {
+ await this.closeWebsocket()
+ this.testData = {
+ show: false,
+ wsConnection: null,
+ senderPrivateKey: null,
+ recieverPublicKey: null,
+ message: null,
+ sentData: '',
+ receivedData: ''
+ }
+ },
sendTestMessage: async function () {
try {
const {data} = await LNbits.api.request(
@@ -423,6 +471,7 @@
data.private_key || ''
)
const event = JSON.parse(data.event_json)[1]
+ this.testData.senderPublicKey = event.pubkey
await this.sendDataToWebSocket(data.event_json)
const subscription = JSON.stringify([
'REQ',
@@ -469,6 +518,16 @@
this.testData.wsConnection.onerror = updateReciveData
this.testData.wsConnection.onclose = updateReciveData
},
+ closeWebsocket: async function () {
+ try {
+ if (this.testData.wsConnection) {
+ this.testData.wsConnection.close()
+ await this.sleep(100)
+ }
+ } catch (error) {
+ console.warn(error)
+ }
+ },
exportlnurldeviceCSV: function () {
var self = this
LNbits.utils.exportCSV(self.relayTable.columns, this.nostrLinks)
@@ -479,9 +538,6 @@
var self = this
this.getRelays()
setInterval(this.getRelays, 5000)
- this.testData.senderPrivateKey =
- this.$q.localStorage.getItem('lnbits.nostrclient.senderPrivateKey') ||
- ''
}
})
diff --git a/views_api.py b/views_api.py
index e7c5f06..12f4f79 100644
--- a/views_api.py
+++ b/views_api.py
@@ -93,8 +93,6 @@ async def api_test_endpoint(data: TestMessage) -> TestMessageResponse:
)
private_key.sign_event(dm)
- print("### api_test_endpoint", data)
-
return TestMessageResponse(private_key=private_key.hex(), public_key=to_public_key, event_json=dm.to_message())
except (ValueError, AssertionError) as ex:
raise HTTPException(