Huge commit. Multiple fixes. Refactored commands. Invitations, resources, template inspection, mnemonic stuff, cli utils, pretty printing, remove unreserve on start, fix connectino requirement for invitations, format cashAddress to lockingBytecode on send, lots and lots of other stuff.

This commit is contained in:
2026-04-06 11:56:09 +00:00
parent b475b23beb
commit 55c75501d5
24 changed files with 3284 additions and 77 deletions

View File

@@ -58,6 +58,7 @@ const menuItems: ListItemData<string>[] = [
{ key: 'import', label: 'Import Invitation', value: 'import' },
{ key: 'invitations', label: 'View Invitations', value: 'invitations' },
{ key: 'new-address', label: 'Generate New Address', value: 'new-address' },
{ key: 'unreserve-all', label: 'Unreserve All Resources', value: 'unreserve-all' },
{ key: 'refresh', label: 'Refresh', value: 'refresh' },
];
@@ -160,6 +161,21 @@ export function WalletStateScreen(): React.ReactElement {
refresh();
}, [refresh]);
// Keep wallet state in sync with invitation lifecycle and updates.
useEffect(() => {
if (!appService) return;
const onWalletStateChanged = () => {
void refresh();
};
appService.on('wallet-state-changed', onWalletStateChanged);
return () => {
appService.off('wallet-state-changed', onWalletStateChanged);
};
}, [appService, refresh]);
/**
* Generates a new receiving address and displays it as a QR code.
*/
@@ -211,6 +227,25 @@ export function WalletStateScreen(): React.ReactElement {
}
}, [appService, setStatus, showError, refresh]);
/**
* Unreserves all reserved UTXOs and refreshes the wallet state.
*/
const unreserveAll = useCallback(async () => {
if (!appService) {
showError('AppService not initialized');
return;
}
try {
setStatus('Unreserving all resources...');
const count = await appService.unreserveAllResources();
showInfo(`Unreserved ${count} resource(s)`);
await refresh();
} catch (error) {
showError(`Failed to unreserve resources: ${error instanceof Error ? error.message : String(error)}`);
}
}, [appService, setStatus, showError, showInfo, refresh]);
/**
* Handles menu action.
*/
@@ -228,11 +263,14 @@ export function WalletStateScreen(): React.ReactElement {
case 'new-address':
generateNewAddress();
break;
case 'unreserve-all':
unreserveAll();
break;
case 'refresh':
refresh();
break;
}
}, [navigate, generateNewAddress, refresh]);
}, [navigate, generateNewAddress, unreserveAll, refresh]);
/**
* Handle menu item activation.