diff --git a/meshchat.py b/meshchat.py
index 69735f0..377668d 100644
--- a/meshchat.py
+++ b/meshchat.py
@@ -1083,20 +1083,29 @@ async def index(request):
})
# get lxmf stamp cost for the provided lxmf.delivery destination hash
- @routes.get("/api/v1/destination/{destination_hash}/lxmf-stamp-cost")
+ @routes.get("/api/v1/destination/{destination_hash}/lxmf-stamp-info")
async def index(request):
# get path params
destination_hash = request.match_info.get("destination_hash", "")
+ # convert destination hash to bytes
+ destination_hash = bytes.fromhex(destination_hash)
+
# get lxmf stamp cost from announce in database
lxmf_stamp_cost = None
- announce = database.Announce.get_or_none(database.Announce.destination_hash == destination_hash)
+ announce = database.Announce.get_or_none(database.Announce.destination_hash == destination_hash.hex())
if announce is not None:
lxmf_stamp_cost = self.parse_lxmf_stamp_cost(announce.app_data)
+ # get outbound ticket expiry for this lxmf destination
+ lxmf_outbound_ticket_expiry = self.message_router.get_outbound_ticket_expiry(destination_hash)
+
return web.json_response({
- "lxmf_stamp_cost": lxmf_stamp_cost,
+ "lxmf_stamp_info": {
+ "stamp_cost": lxmf_stamp_cost,
+ "outbound_ticket_expiry": lxmf_outbound_ticket_expiry,
+ },
})
# get interface stats
diff --git a/src/frontend/components/messages/ConversationViewer.vue b/src/frontend/components/messages/ConversationViewer.vue
index 5e29852..1864ed4 100644
--- a/src/frontend/components/messages/ConversationViewer.vue
+++ b/src/frontend/components/messages/ConversationViewer.vue
@@ -20,7 +20,7 @@
<{{ selectedPeer.destination_hash }}>
{{ selectedPeerPath.hops }} {{ selectedPeerPath.hops === 1 ? 'hop' : 'hops' }} away
- • Stamp Cost {{ selectedPeerLxmfStampCost }}
+ • Stamp Cost {{ selectedPeerLxmfStampInfo.stamp_cost }}
@@ -369,6 +369,7 @@ import DialogUtils from "../../js/DialogUtils";
import NotificationUtils from "../../js/NotificationUtils";
import WebSocketConnection from "../../js/WebSocketConnection";
import AddAudioButton from "./AddAudioButton.vue";
+import moment from "moment";
export default {
name: 'ConversationViewer',
@@ -384,7 +385,7 @@ export default {
return {
selectedPeerPath: null,
- selectedPeerLxmfStampCost: null,
+ selectedPeerLxmfStampInfo: null,
lxmfMessagesRequestSequence: 0,
chatItems: [],
@@ -460,7 +461,7 @@ export default {
}
this.getPeerPath();
- this.getPeerLxmfStampCost();
+ this.getPeerLxmfStampInfo();
// load 1 page of previous messages
await this.loadPrevious();
@@ -530,9 +531,9 @@ export default {
const json = JSON.parse(message.data);
switch(json.type){
case 'announce': {
- // update stamp cost if an announce is received from the selected peer
+ // update stamp info if an announce is received from the selected peer
if(json.announce.destination_hash === this.selectedPeer?.destination_hash){
- await this.getPeerLxmfStampCost();
+ await this.getPeerLxmfStampInfo();
}
break;
}
@@ -641,19 +642,19 @@ export default {
}
},
- async getPeerLxmfStampCost() {
+ async getPeerLxmfStampInfo() {
- // clear previous stamp cost
- this.selectedPeerLxmfStampCost = null;
+ // clear previous stamp info
+ this.selectedPeerLxmfStampInfo = null;
if(this.selectedPeer){
try {
- // get lxmf stamp cost
- const response = await window.axios.get(`/api/v1/destination/${this.selectedPeer.destination_hash}/lxmf-stamp-cost`);
+ // get lxmf stamp info
+ const response = await window.axios.get(`/api/v1/destination/${this.selectedPeer.destination_hash}/lxmf-stamp-info`);
// update ui
- this.selectedPeerLxmfStampCost = response.data.lxmf_stamp_cost;
+ this.selectedPeerLxmfStampInfo = response.data.lxmf_stamp_info;
} catch(e) {
console.log(e);
@@ -664,7 +665,10 @@ export default {
onDestinationPathClick(path) {
DialogUtils.alert(`${path.hops} ${ path.hops === 1 ? 'hop' : 'hops' } away via ${path.next_hop_interface}`);
},
- onStampCostClick(stampCost) {
+ onStampInfoClick(stampInfo) {
+
+ const stampCost = stampInfo.stamp_cost;
+ const outboundTicketExpiry = stampInfo.outbound_ticket_expiry;
// determine estimated time to generate a stamp
var estimatedTimeForStamp = "";
@@ -688,9 +692,14 @@ export default {
estimatedTimeForStamp = "0 seconds";
}
- DialogUtils.alert(`This peer has enabled stamp security.\n\nYour device must solve an automated proof of work task each time you send them a message.\n\nTime per message: ${estimatedTimeForStamp}`);
+ // check if we have an outbound ticket available
+ if(outboundTicketExpiry != null){
+ estimatedTimeForStamp = `instant (ticket expires ${moment(outboundTicketExpiry * 1000).fromNow()})`;
+ }
- },
+ DialogUtils.alert(`This peer has enabled stamp security.\n\nYour device must have a ticket, or solve an automated proof of work task each time you send them a message.\n\nTime per message: ${estimatedTimeForStamp}`);
+
+ },
scrollMessagesToBottom: function() {
// next tick waits for the ui to have the new elements added
this.$nextTick(() => {