gitmark 0.0.74 → 0.0.75
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/bin/git-mark.js +24 -4
- package/package.json +1 -1
package/bin/git-mark.js
CHANGED
|
@@ -194,7 +194,7 @@ function getHead() {
|
|
|
194
194
|
function getPrivkey() {
|
|
195
195
|
try { return gitExec('git config --local nostr.privkey'); } catch { return null; }
|
|
196
196
|
}
|
|
197
|
-
function setPrivkey(key) { gitExec(`git config --local nostr.privkey ${key}`); }
|
|
197
|
+
function setPrivkey(key) { gitExec(`git config --local nostr.privkey '${key}'`); }
|
|
198
198
|
function isGitRoot() { return existsSync('.git'); }
|
|
199
199
|
|
|
200
200
|
// --- Trail file helpers ---
|
|
@@ -218,13 +218,13 @@ function loadPrivateState() {
|
|
|
218
218
|
}
|
|
219
219
|
function savePrivateState(state, chain, head) {
|
|
220
220
|
const txoUri = `txo:${chain}:${state.txid}:${state.vout}?amount=${state.amount}${head ? '&commit=' + head : ''}`;
|
|
221
|
-
gitExec(`git config --local gitmark.txo ${txoUri}`);
|
|
221
|
+
gitExec(`git config --local gitmark.txo '${txoUri}'`);
|
|
222
222
|
}
|
|
223
223
|
function isDirty() {
|
|
224
224
|
try { return gitExec('git config --local gitmark.dirty') !== 'false'; } catch { return true; }
|
|
225
225
|
}
|
|
226
226
|
function addGitNote(commitHash, note) {
|
|
227
|
-
try { gitExec(`git notes add -f -m ${note} ${commitHash}`); } catch { /* ignore if no commits */ }
|
|
227
|
+
try { gitExec(`git notes add -f -m '${note}' '${commitHash}'`); } catch { /* ignore if no commits */ }
|
|
228
228
|
}
|
|
229
229
|
function loadTrailFromNotes() {
|
|
230
230
|
const trail = loadTrail();
|
|
@@ -336,7 +336,11 @@ async function cmdInit(args) {
|
|
|
336
336
|
|
|
337
337
|
savePrivateState({ txid: newTxid, vout: 0, amount: outputAmount }, chain);
|
|
338
338
|
const xonly = pubkey.slice(2); // 64-char x-only Nostr pubkey
|
|
339
|
-
|
|
339
|
+
// Insert @id first
|
|
340
|
+
const reordered = { '@id': `txo:${chain}:${newTxid}:0?amount=${outputAmount}&pubkey=${xonly}`, '@type': trail['@type'] };
|
|
341
|
+
for (const [k, v] of Object.entries(trail)) { if (k !== '@type') reordered[k] = v; }
|
|
342
|
+
Object.keys(trail).forEach(k => delete trail[k]);
|
|
343
|
+
Object.assign(trail, reordered);
|
|
340
344
|
console.log(`Funded: ${outputAmount} sats (txid: ${newTxid})`);
|
|
341
345
|
}
|
|
342
346
|
|
|
@@ -436,6 +440,22 @@ async function cmdInfo() {
|
|
|
436
440
|
console.log(`Current address: ${currentAddr}`);
|
|
437
441
|
console.log(`Last commit: ${trail.states[trail.states.length - 1]}`);
|
|
438
442
|
console.log(`Last TXO: ${trail.txo[trail.txo.length - 1]}`);
|
|
443
|
+
|
|
444
|
+
// Check confirmation status of latest tx
|
|
445
|
+
const explorer = CHAINS[trail.chain]?.explorer;
|
|
446
|
+
if (explorer && priv) {
|
|
447
|
+
try {
|
|
448
|
+
const txResp = await fetch(`${explorer}/tx/${priv.txid}`);
|
|
449
|
+
if (txResp.ok) {
|
|
450
|
+
const txData = await txResp.json();
|
|
451
|
+
if (txData.status?.confirmed) {
|
|
452
|
+
console.log(`Status: ✓ confirmed (block ${txData.status.block_height})`);
|
|
453
|
+
} else {
|
|
454
|
+
console.log(`Status: ⏳ unconfirmed`);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
} catch (e) {}
|
|
458
|
+
}
|
|
439
459
|
}
|
|
440
460
|
if (priv) {
|
|
441
461
|
console.log(`Balance: ${priv.amount} sats`);
|