Skip to content

Commit 9ac694a

Browse files
committed
fix: clean wallet ID display when server registration unavailable
1 parent c189fc8 commit 9ac694a

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

bin/coinpay

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async function walletImport(opts) {
232232
console.log('\n╔══════════════════════════════════════════════════════════════╗');
233233
console.log('║ WALLET IMPORTED ║');
234234
console.log('╠══════════════════════════════════════════════════════════════╣');
235-
if (walletId) console.log(`║ Wallet ID: ${walletId}`);
235+
console.log(`║ Wallet ID: ${walletId || '(local only — server registration pending)'}`);
236236
console.log(`║ Chains: ${chains.join(', ')}`);
237237
console.log('╚══════════════════════════════════════════════════════════════╝\n');
238238

@@ -249,7 +249,7 @@ async function walletUnlock(opts) {
249249
console.log('\n╔══════════════════════════════════════════════════════════════╗');
250250
console.log('║ WALLET UNLOCKED ║');
251251
console.log('╠══════════════════════════════════════════════════════════════╣');
252-
console.log(`║ Wallet ID: ${data.walletId || 'N/A'}`);
252+
console.log(`║ Wallet ID: ${data.walletId || '(local only)'}`);
253253
console.log(`║ Chains: ${(data.chains || []).join(', ')}`);
254254
console.log(`║ Mnemonic: ${data.mnemonic}`);
255255
console.log('╚══════════════════════════════════════════════════════════════╝\n');

packages/sdk/bin/coinpay.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,16 @@ async function handleWallet(subcommand, args, flags) {
823823
print.info('Importing wallet...');
824824

825825
try {
826-
const wallet = await WalletClient.fromSeed(mnemonic, {
827-
chains,
828-
baseUrl,
829-
});
830-
831-
const walletId = wallet.getWalletId();
826+
let walletId = null;
827+
try {
828+
const wallet = await WalletClient.fromSeed(mnemonic, {
829+
chains,
830+
baseUrl,
831+
});
832+
walletId = wallet.getWalletId();
833+
} catch (serverErr) {
834+
print.warn(`Server registration failed (wallet saved locally only): ${serverErr.message || serverErr}`);
835+
}
832836

833837
// Save encrypted locally (unless --no-save)
834838
if (!noSave) {
@@ -860,9 +864,9 @@ async function handleWallet(subcommand, args, flags) {
860864
config.walletFile = walletFile;
861865
saveConfig(config);
862866

863-
print.success(`Wallet imported: ${walletId}`);
867+
print.success(walletId ? `Wallet imported (ID: ${walletId})` : 'Wallet imported (local only)');
864868
} catch (error) {
865-
print.error(error.message);
869+
print.error(error.message || String(error));
866870
}
867871
break;
868872
}
@@ -878,7 +882,7 @@ async function handleWallet(subcommand, args, flags) {
878882
const mnemonic = await getDecryptedMnemonic(flags);
879883

880884
print.success('Wallet unlocked');
881-
print.info(`Wallet ID: ${config.walletId || 'unknown'}`);
885+
print.info(`Wallet ID: ${config.walletId || '(local only)'}`);
882886
print.info(`Wallet file: ${walletFile}`);
883887

884888
if (flags.show) {

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@profullstack/coinpay",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "CoinPay SDK & CLI — Accept cryptocurrency payments (BTC, ETH, SOL, POL, BCH, USDC) with wallet and swap support",
55
"type": "module",
66
"main": "./src/index.js",

0 commit comments

Comments
 (0)