deviant/scripts/_check-escrow.mjs

16 lines
987 B
JavaScript
Raw Permalink Normal View History

import { ElectrumNetworkProvider } from 'cashscript';
const prov = new ElectrumNetworkProvider('chipnet');
const CONTRACT = 'bchtest:rdj5sng0p30q983sjmc8ds7xujh828j62cztchetqdxka5vf3y84jd5qk94mu';
const D = 'bchtest:qzjqnzgjz7w9tdflpz6ufx0rnrnfu4hsps9rznw4dl';
const ASM = '09af8a5b2fc2c9a2449045a8d5a6aa60db493989682eca257a57fa8d75d67231';
const TX = 'e9b0d666180270935b70769dc61f91c95643fd587f29f18bb85a36d06a40a148';
const covUtxos = await prov.getUtxos(CONTRACT);
const fromMyTx = covUtxos.filter(u => u.txid === TX);
console.log(`Contract UTXOs from tx ${TX.slice(0, 12)}…: ${fromMyTx.length}`);
for (const u of fromMyTx) console.log(` vout ${u.vout} · ${u.satoshis} sats · token ${u.token?.amount} of ${u.token?.category?.slice(0, 10)}…`);
const dUtxos = await prov.getUtxos(D);
const dAsm = dUtxos.filter(u => u.token?.category === ASM).reduce((s, u) => s + BigInt(u.token.amount), 0n);
console.log(`Wallet D remaining ASM: ${dAsm} (was 1000, escrowed 10, expect 990)`);