Bug(NWC): Unable to see balance and transactions list on wallet
What happens Hi Damus Team,
I’m currently working on integrating Nostr Wallet Connect (NWC) in the Zeus Wallet. The implementation works fine with some other Nostr clients like getalby, but I’m experiencing an issue with Damus.
When connecting with Damus, the wallet service does receive events from the app, and I can send data back as well. However, on the Damus wallet screen it only shows the loading skeleton for balance and transactions, and never resolves.
I’ve tried different approaches, but the issue persists. I’m using the @getalby/sdk package to build this feature. Could you please review the simple script below and let me know if I’ve done something wrong in my implementation, or if this might be an issue on the Damus side?
Simple Test Script
import 'websocket-polyfill'; // required in node.jsimport { generateSecretKey, getPublicKey } from 'nostr-tools'; import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
const walletServiceSecretKey = bytesToHex(generateSecretKey()); const walletServicePubkey = getPublicKey(hexToBytes(walletServiceSecretKey));
const clientSecretKey = bytesToHex(generateSecretKey()); const clientPubkey = getPublicKey(hexToBytes(clientSecretKey));
const relayUrl = 'wss://relay.getalby.com/v1';
const nwcUrl = nostr+walletconnect://${walletServicePubkey}?relay=${relayUrl}&secret=${clientSecretKey};
console.info('enter this NWC URL in a client: ', nwcUrl);
import { nwc } from '@getalby/sdk';
const walletService = new nwc.NWCWalletService({ relayUrl, });
console.info('checking connection to relay'); await walletService.publishWalletServiceInfoEvent( walletServiceSecretKey, ['get_info', 'get_balance', 'get_transactions', 'list_transactions'], [] ); console.info('published wallet service info event');
const keypair = new nwc.NWCWalletServiceKeyPair( walletServiceSecretKey, clientPubkey );
const unsub = await walletService.subscribe(keypair, { getInfo: params => { console.log( '📥 Received getInfo request:', JSON.stringify(params, null, 2) ); const response = { result: { methods: [ 'get_info', 'get_balance', 'list_transactions', 'get_transactions', ], //... add other fields here }, error: undefined, }; console.log( '📤 Sending getInfo response:', JSON.stringify(response, null, 2) ); return Promise.resolve(response); }, getBalance: params => { console.log( '📥 Received getBalance request:', JSON.stringify(params, null, 2) ); const response = { result: { balance: 1000000000, currency: 'sats', }, error: undefined, }; console.log( '📤 Sending getBalance response:', JSON.stringify(response, null, 2) ); return Promise.resolve(response); },
listTransactions: params => { console.log( '📥 Received listTransactions request:', JSON.stringify(params, null, 2) ); const response = { result: { transactions: [ { type: 'incoming', invoice: 'lnbc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh5mkmrjs9qwrrc7sp9qy9js', description: 'Test incoming transaction', description_hash: null, preimage: null, payment_hash: 'abc123def456', amount: 1000, fees_paid: 0, settled_at: Math.floor(Date.now() / 1000), created_at: Math.floor(Date.now() / 1000), bolt11: 'lnbc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh5mkmrjs9qwrrc7sp9qy9js', }, { type: 'outgoing', invoice: 'lnbc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh5mkmrjs9qwrrc7sp9qy9js', description: 'Test outgoing transaction', description_hash: null, preimage: null, payment_hash: 'def456abc789', amount: 500, fees_paid: 1, settled_at: Math.floor(Date.now() / 1000) - 3600, created_at: Math.floor(Date.now() / 1000) - 3600, bolt11: 'lnbc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh5mkmrjs9qwrrc7sp9qy9js', }, ], total_count: 2, }, error: undefined, }; console.log( '📤 Sending listTransactions response:', JSON.stringify(response, null, 2) ); return Promise.resolve(response); },
getTransactions: params => { console.log( '📥 Received getTransactions request:', JSON.stringify(params, null, 2) ); const response = { result: { transactions: [ { type: 'incoming', invoice: 'lnbc...', description: 'Test transaction', description_hash: null, preimage: null, payment_hash: 'abc123', amount: 1000, fees_paid: 0, settled_at: Math.floor(Date.now() / 1000), created_at: Math.floor(Date.now() / 1000), }, ], }, error: undefined, }; console.log( '📤 Sending getTransactions response:', JSON.stringify(response, null, 2) ); return Promise.resolve(response); },
// Add error handler for unsupported methods
onUnsupportedMethod: (method, params) => {
console.log('❌ Received unsupported method:', method);
console.log('📥 Request params:', JSON.stringify(params, null, 2));
const response = {
result: undefined,
error: {
code: 'NOT_IMPLEMENTED',
message: Method ${method} is not implemented,
},
};
console.log(
'📤 Sending error response:',
JSON.stringify(response, null, 2)
);
return Promise.resolve(response);
},
});
console.info('Waiting for events...');
// Log when subscription is established console.log('✅ Subscription established successfully'); process.on('SIGINT', function () { console.info('Caught interrupt signal');
unsub(); walletService.close();
process.exit(); });
Link to noteID, npub Provide link to relevant noteID, npub etc.
Screenshots/video recording If applicable, add screenshots to help explain your problem.
** Versions ** Damus version: [e.g. 1.7.2 (1()] Operating system version: [e.g. iOS 17.2.1] Device: e.g. iPhone 13 Pro
Steps To Reproduce Steps to reproduce the behavior:
- Open Damus
- Tap on ___
- Action ____
Additional context Add any other context about the problem here.
@jb55 , would you please take a look?
@danieldaquino has been investigating NWC behavior recently - can you took a look ser
@alltheseas , would you please check my simple script, if i am doing something wrong, or if that is a Damus issue?
@alltheseas, please would you take a quick look at my sample script? If that is a Zeus issue, I will fix them, or if that is a Damus issue, so we are just aware of that.
Thanks for sharing.
There are other things in the backlog that the Damus dev team is working on in the near term.
Devs will tag you here if your assistance is needed.
@alltheseas I don't think this issue is related to Zeus Wallet, because even using the sample script, I am unable to load the balance and transaction list mentioned in the issue description