Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d41680297 | ||
|
|
b2a50376df | ||
|
|
3c4be89ead |
@@ -637,6 +637,7 @@
|
||||
<button id="btnCheckProofs" class="btn cashuBtn" type="button" style="margin-bottom: 10px;">Check Proofs with Mints</button>
|
||||
<div id="divCheckProofsResult">No proof check run yet.</div>
|
||||
<button id="btnRefreshWallet" class="btn cashuBtn" type="button">Refresh Wallet State</button>
|
||||
<button id="btnRepublishWallet" class="btn cashuBtn" type="button" style="margin-top: 5px;">Republish Wallet (kind 17375)</button>
|
||||
</div>
|
||||
|
||||
<div id="divZapsSection" class="sidenavSection">
|
||||
@@ -728,7 +729,7 @@
|
||||
import { initBlossomSection, updateBlossomSection } from './js/blossom-ui.mjs';
|
||||
|
||||
import { initAiSectionWithLocalConfig } from './js/ai-ui.mjs';
|
||||
import { createCashuWalletController } from './js/cashu-wallet.mjs?v=mint-discovery-3';
|
||||
import { createCashuWalletController } from './js/cashu-wallet.mjs?v=nip60-republish-1';
|
||||
|
||||
const versionInfo = await getVersion();
|
||||
const VERSION = versionInfo.VERSION;
|
||||
@@ -2348,6 +2349,23 @@
|
||||
}
|
||||
});
|
||||
|
||||
const btnRepublishWallet = document.getElementById('btnRepublishWallet');
|
||||
btnRepublishWallet?.addEventListener('click', async () => {
|
||||
try {
|
||||
if (!walletController?.hasWallet?.()) {
|
||||
setStatus('No wallet to republish', true);
|
||||
return;
|
||||
}
|
||||
setStatus('Republishing wallet event (kind 17375)...');
|
||||
await walletController.republishWallet();
|
||||
await refreshAllWalletViews();
|
||||
setStatus('Wallet republished successfully');
|
||||
} catch (error) {
|
||||
console.error('[cashu.html] Republish wallet failed:', error);
|
||||
setStatus(error.message || 'Republish failed', true);
|
||||
}
|
||||
});
|
||||
|
||||
btnSaveZapsSettings?.addEventListener('click', async () => {
|
||||
try {
|
||||
const amount = Number(inpZapDefaultAmount?.value || 0);
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
walletRemoveMint,
|
||||
walletGetTransactions,
|
||||
walletShutdown,
|
||||
walletRepublish,
|
||||
walletPublishMintList,
|
||||
walletFetchMintList,
|
||||
onWalletStatus,
|
||||
@@ -397,6 +398,16 @@ export async function createCashuWalletController({ pubkey, relayUrls = [] } = {
|
||||
}
|
||||
}
|
||||
|
||||
async function republishWallet() {
|
||||
await ensureWallet();
|
||||
const result = await walletRepublish();
|
||||
if (Array.isArray(result?.mints)) {
|
||||
mintsCache = uniqueMints(result.mints);
|
||||
}
|
||||
applyBalancePayload(result || {});
|
||||
return { mints: [...mintsCache] };
|
||||
}
|
||||
|
||||
cleanupFns.push(onWalletStatus((payload) => {
|
||||
if (typeof payload?.hasWallet === 'boolean') {
|
||||
hasWalletCache = payload.hasWallet;
|
||||
@@ -431,6 +442,7 @@ export async function createCashuWalletController({ pubkey, relayUrls = [] } = {
|
||||
waitForDeposit,
|
||||
getTransactionHistory,
|
||||
publishMintList,
|
||||
republishWallet,
|
||||
fetchRecipientMintList,
|
||||
onWalletEvent,
|
||||
subscribeTransactions,
|
||||
|
||||
@@ -184,7 +184,7 @@ export async function initNDKPage(options = {}) {
|
||||
|
||||
// All pages in www/ directory, so worker path is always the same.
|
||||
// Include explicit worker revision token so updated SharedWorker code is guaranteed to restart.
|
||||
const WORKER_REVISION = 'nip60-tagarray-fix-1';
|
||||
const WORKER_REVISION = 'nip60-privkey-ensure-1';
|
||||
const workerPath = `./ndk-worker.js?v=${encodeURIComponent(VERSION)}&wr=${encodeURIComponent(WORKER_REVISION)}`;
|
||||
|
||||
// Initialize NDK SharedWorker (shared across all tabs/pages)
|
||||
@@ -1425,6 +1425,10 @@ export function walletShutdown() {
|
||||
return sendWorkerRequest('walletShutdown', {}, 10000, 'walletShutdown timeout');
|
||||
}
|
||||
|
||||
export function walletRepublish() {
|
||||
return sendWorkerRequest('walletRepublish', {}, 120000, 'walletRepublish timeout');
|
||||
}
|
||||
|
||||
export function walletPublishMintList(relays = [], receiveMints = []) {
|
||||
return sendWorkerRequest('walletPublishMintList', { relays, receiveMints }, 25000, 'walletPublishMintList timeout');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"VERSION": "v0.7.20",
|
||||
"VERSION_NUMBER": "0.7.20",
|
||||
"BUILD_DATE": "2026-06-25T17:34:24.155Z"
|
||||
"VERSION": "v0.7.23",
|
||||
"VERSION_NUMBER": "0.7.23",
|
||||
"BUILD_DATE": "2026-06-25T18:01:01.940Z"
|
||||
}
|
||||
|
||||
@@ -2843,6 +2843,15 @@ async function publishDirectProofs(debugContext = null) {
|
||||
}
|
||||
log('delete old 7375 done');
|
||||
|
||||
// Ensure a nutzap privkey exists before building the wallet payload.
|
||||
// If the user's old 17375 didn't have one (or hydration failed),
|
||||
// this auto-generates one so it's always included in the republish.
|
||||
try {
|
||||
ensureDirectNutzapP2pk();
|
||||
} catch (err) {
|
||||
log('ensureDirectNutzapP2pk failed during publish', { error: err?.message || String(err) });
|
||||
}
|
||||
|
||||
// NIP-60 standard: public "mint" tags are visible on the event;
|
||||
// the privkey lives in the encrypted content as a "privkey" tag.
|
||||
// The "pubkey" tag does NOT belong on kind 17375 (it belongs on
|
||||
@@ -4304,6 +4313,30 @@ async function handleWalletCheckProofs(requestId, port) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleWalletRepublish(requestId, port) {
|
||||
try {
|
||||
if (!ndk || !currentPubkey) {
|
||||
port.postMessage({ type: 'response', requestId, error: 'NDK not ready' });
|
||||
return;
|
||||
}
|
||||
await ensureDirectWalletLoaded();
|
||||
await publishDirectProofs({ traceId: 'walletRepublish' });
|
||||
const payload = getWalletBalancePayload();
|
||||
port.postMessage({
|
||||
type: 'response',
|
||||
requestId,
|
||||
data: {
|
||||
success: true,
|
||||
mints: getDirectWalletMints(),
|
||||
...payload
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('[Worker] handleWalletRepublish failed:', error?.message || error);
|
||||
port.postMessage({ type: 'response', requestId, error: error.message || 'Republish failed' });
|
||||
}
|
||||
}
|
||||
|
||||
function handleWalletShutdown(requestId, port) {
|
||||
try {
|
||||
clearWalletListeners();
|
||||
@@ -6500,7 +6533,11 @@ self.onconnect = (event) => {
|
||||
case 'walletCheckProofs':
|
||||
await handleWalletCheckProofs(requestId, port);
|
||||
break;
|
||||
|
||||
|
||||
case 'walletRepublish':
|
||||
await handleWalletRepublish(requestId, port);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn('[Worker] Unknown message type:', type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user