@paytaca/opencode-plugin 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/wallet.js +17 -29
- package/package.json +1 -1
- package/src/wallet.ts +16 -30
package/dist/wallet.js
CHANGED
|
@@ -189,44 +189,32 @@ async function createWallet() {
|
|
|
189
189
|
try {
|
|
190
190
|
// Generate a new wallet using paytaca CLI
|
|
191
191
|
// This will create a wallet and display the mnemonic
|
|
192
|
-
const { stdout, stderr } = await execAsync(`"${PAYTACA_CMD}" wallet create
|
|
192
|
+
const { stdout, stderr } = await execAsync(`"${PAYTACA_CMD}" wallet create`);
|
|
193
193
|
let output = stdout.toString();
|
|
194
194
|
if (!output && stderr) {
|
|
195
195
|
output = stderr.toString();
|
|
196
196
|
}
|
|
197
|
-
// Try to parse JSON output if available
|
|
198
|
-
try {
|
|
199
|
-
const jsonOutput = JSON.parse(output);
|
|
200
|
-
if (jsonOutput.mnemonic) {
|
|
201
|
-
// Show warning to user
|
|
202
|
-
console.log('\\n⚠️ IMPORTANT: Your wallet has been created!');
|
|
203
|
-
console.log('\\nSAVE THIS RECOVERY PHRASE SECURELY:');
|
|
204
|
-
console.log('═'.repeat(60));
|
|
205
|
-
console.log(jsonOutput.mnemonic);
|
|
206
|
-
console.log('═'.repeat(60));
|
|
207
|
-
console.log('\\nWithout this phrase, you CANNOT recover your funds if you');
|
|
208
|
-
console.log('lose access to this device. Write it down and store it safely.\\n');
|
|
209
|
-
return {
|
|
210
|
-
exists: true,
|
|
211
|
-
hash: jsonOutput.hash,
|
|
212
|
-
address: jsonOutput.address,
|
|
213
|
-
balance: '0 BCH',
|
|
214
|
-
mnemonic: jsonOutput.mnemonic
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
// Fall through to regex parsing
|
|
220
|
-
}
|
|
221
197
|
// Parse from text output
|
|
222
198
|
const hashMatch = output.match(/Wallet hash:\s*(.+)/i);
|
|
223
199
|
const addressMatch = output.match(/Address:\s*(.+)/i);
|
|
224
|
-
|
|
225
|
-
|
|
200
|
+
// Extract mnemonic from numbered seed phrase list
|
|
201
|
+
const phraseSection = output.match(/Seed phrase:\s*\n([\s\S]*?)(?=\n\s*Wallet hash)/i);
|
|
202
|
+
let mnemonic = undefined;
|
|
203
|
+
if (phraseSection) {
|
|
204
|
+
const words = [];
|
|
205
|
+
for (const line of phraseSection[1].trim().split('\n')) {
|
|
206
|
+
const m = line.match(/^\s*\d+\.\s+(\w+)/);
|
|
207
|
+
if (m)
|
|
208
|
+
words.push(m[1]);
|
|
209
|
+
}
|
|
210
|
+
if (words.length >= 12)
|
|
211
|
+
mnemonic = words.join(' ');
|
|
212
|
+
}
|
|
213
|
+
if (mnemonic) {
|
|
226
214
|
console.log('\\n⚠️ IMPORTANT: Your wallet has been created!');
|
|
227
215
|
console.log('\\nSAVE THIS RECOVERY PHRASE SECURELY:');
|
|
228
216
|
console.log('═'.repeat(60));
|
|
229
|
-
console.log(
|
|
217
|
+
console.log(mnemonic);
|
|
230
218
|
console.log('═'.repeat(60));
|
|
231
219
|
console.log('\\nWithout this phrase, you CANNOT recover your funds if you');
|
|
232
220
|
console.log('lose access to this device. Write it down and store it safely.\\n');
|
|
@@ -236,7 +224,7 @@ async function createWallet() {
|
|
|
236
224
|
hash: hashMatch ? hashMatch[1].trim() : undefined,
|
|
237
225
|
address: addressMatch ? addressMatch[1].trim() : undefined,
|
|
238
226
|
balance: '0 BCH',
|
|
239
|
-
mnemonic
|
|
227
|
+
mnemonic
|
|
240
228
|
};
|
|
241
229
|
}
|
|
242
230
|
catch (err) {
|
package/package.json
CHANGED
package/src/wallet.ts
CHANGED
|
@@ -163,48 +163,34 @@ export async function createWallet(): Promise<WalletInfo> {
|
|
|
163
163
|
try {
|
|
164
164
|
// Generate a new wallet using paytaca CLI
|
|
165
165
|
// This will create a wallet and display the mnemonic
|
|
166
|
-
const { stdout, stderr } = await execAsync(`"${PAYTACA_CMD}" wallet create
|
|
166
|
+
const { stdout, stderr } = await execAsync(`"${PAYTACA_CMD}" wallet create`);
|
|
167
167
|
|
|
168
168
|
let output = stdout.toString();
|
|
169
169
|
if (!output && stderr) {
|
|
170
170
|
output = stderr.toString();
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
// Try to parse JSON output if available
|
|
174
|
-
try {
|
|
175
|
-
const jsonOutput = JSON.parse(output);
|
|
176
|
-
if (jsonOutput.mnemonic) {
|
|
177
|
-
// Show warning to user
|
|
178
|
-
console.log('\\n⚠️ IMPORTANT: Your wallet has been created!');
|
|
179
|
-
console.log('\\nSAVE THIS RECOVERY PHRASE SECURELY:');
|
|
180
|
-
console.log('═'.repeat(60));
|
|
181
|
-
console.log(jsonOutput.mnemonic);
|
|
182
|
-
console.log('═'.repeat(60));
|
|
183
|
-
console.log('\\nWithout this phrase, you CANNOT recover your funds if you');
|
|
184
|
-
console.log('lose access to this device. Write it down and store it safely.\\n');
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
exists: true,
|
|
188
|
-
hash: jsonOutput.hash,
|
|
189
|
-
address: jsonOutput.address,
|
|
190
|
-
balance: '0 BCH',
|
|
191
|
-
mnemonic: jsonOutput.mnemonic
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
} catch {
|
|
195
|
-
// Fall through to regex parsing
|
|
196
|
-
}
|
|
197
|
-
|
|
198
173
|
// Parse from text output
|
|
199
174
|
const hashMatch = output.match(/Wallet hash:\s*(.+)/i);
|
|
200
175
|
const addressMatch = output.match(/Address:\s*(.+)/i);
|
|
201
|
-
const mnemonicMatch = output.match(/Recovery phrase[\s\S]*?([a-z]+(?:\s+[a-z]+){11,23})/i);
|
|
202
176
|
|
|
203
|
-
|
|
177
|
+
// Extract mnemonic from numbered seed phrase list
|
|
178
|
+
const phraseSection = output.match(/Seed phrase:\s*\n([\s\S]*?)(?=\n\s*Wallet hash)/i);
|
|
179
|
+
let mnemonic = undefined;
|
|
180
|
+
if (phraseSection) {
|
|
181
|
+
const words = [];
|
|
182
|
+
for (const line of phraseSection[1].trim().split('\n')) {
|
|
183
|
+
const m = line.match(/^\s*\d+\.\s+(\w+)/);
|
|
184
|
+
if (m) words.push(m[1]);
|
|
185
|
+
}
|
|
186
|
+
if (words.length >= 12) mnemonic = words.join(' ');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (mnemonic) {
|
|
204
190
|
console.log('\\n⚠️ IMPORTANT: Your wallet has been created!');
|
|
205
191
|
console.log('\\nSAVE THIS RECOVERY PHRASE SECURELY:');
|
|
206
192
|
console.log('═'.repeat(60));
|
|
207
|
-
console.log(
|
|
193
|
+
console.log(mnemonic);
|
|
208
194
|
console.log('═'.repeat(60));
|
|
209
195
|
console.log('\\nWithout this phrase, you CANNOT recover your funds if you');
|
|
210
196
|
console.log('lose access to this device. Write it down and store it safely.\\n');
|
|
@@ -215,7 +201,7 @@ export async function createWallet(): Promise<WalletInfo> {
|
|
|
215
201
|
hash: hashMatch ? hashMatch[1].trim() : undefined,
|
|
216
202
|
address: addressMatch ? addressMatch[1].trim() : undefined,
|
|
217
203
|
balance: '0 BCH',
|
|
218
|
-
mnemonic
|
|
204
|
+
mnemonic
|
|
219
205
|
};
|
|
220
206
|
} catch (err: any) {
|
|
221
207
|
console.error('Failed to create wallet:', err.message || err);
|