Lines 1-21javascript
1var bsvSmartContract=(()=>{var xf=Object.create;var Fn=Object.defineProperty;var yf=Object.getOwnPropertyDescriptor;var wf=Object.getOwnPropertyNames;var bf=Object.getPrototypeOf,Sf=Object.prototype.hasOwnProperty;var Ef=(t,e,r)=>e in t?Fn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ve=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Oe=(t,e,r)=>()=>{if(r)throw r[0];try{retur ...
2`)};tt.prototype._generateLeftExtractionASM=function(t,e){var r=[{name:"nVersion",len:4,offset:0},{name:"hashPrevouts",len:32,offset:4},{name:"hashSequence",len:32,offset:36},{name:"outpoint_txid",len:32,offset:68},{name:"outpoint_vout",len:4,offset:100}],n=r.find(function(o){return o.name===t});if(!n)throw new Error("Field not found in LEFT fields: "+t);var i=[];return e?i=["# \u{1F504} Extract "+t+" from LEFT side (bidirectional strategy)",n.offset+" OP_SPLIT # Skip to field: [prefix, remainder]","OP_NIP # Drop prefix (OP_SPLIT leaves remainder on top): [remainde ...
3`)};tt.prototype._generateDynamicExtractionASM=function(t,e){var r=104+t.scriptLenSize;return["# \u{1F3AF} Extract scriptCode DYNAMICALLY with CompactSize varint support",r+" OP_SPLIT # Skip left zone + scriptLen varint: [left_zone, remainder]","OP_NIP # Drop left (OP_SPLIT leaves remainder on top): [remainder]",t.scriptLen+" OP_SPLIT # Extract scriptCode: [scriptCode, right_zone]","OP_DROP # Clean up: [scriptCode]","# \u2705 Result: scriptCode extracted with "+t.scriptLenSize+"-byte varint awareness"].join(
4`)};tt.prototype._generateScriptLenExtractionASM=function(t,e){return["# \u{1F3AF} Extract scriptLen CompactSize varint ("+t.scriptLenSize+" bytes)","104 OP_SPLIT # Skip left fixed fields: [left_zone, remainder]","OP_NIP # Drop left (OP_SPLIT leaves remainder on top): [remainder]",t.scriptLenSize+" OP_SPLIT # Extract varint: [scriptLen_varint, suffix]","OP_DROP # Clean up: [scriptLen_varint]","# \u2705 Result: CompactSize varint (decode off-chain to get "+t.scriptLen+")"].join(`
5`)};tt.prototype._extractSpecificField=function(t,e){var r=e[t];return r?E.Buffer.from(r,"hex"):null};tt.prototype._interpretField=function(t,e,r){if(!e)return null;var n
6`),Object.keys(t.wallets).length>0&&(Bt("\u{1F45B} Registered Wallets:"),Object.entries(t.wallets).forEach(([e,r])=>{Bt(` ${e}: ${r.utxos.length} UTXOs, ${r.totalValue} sats`)})),t}function Ka(){let t=bo.join(__dirname,"wallet.json");if(!Pr.existsSync(t))return Bt("\u274C No wallet.json found to import"),!1;try{let e=JSON.parse(Pr.readFileSync(t,"utf8"));Bt("\u{1F4E5} Importing wallet from wallet.json...");let r={registeredAt:new Date().toISOString(),utxos:e.availableUTXOs||[e.utxo]};return Ga(e.wallet.address,r),Bt("\u2705 Wallet imported successfully"),!0}catch(e){return console.error("\u27 ...
7`).map(function(r){return r.split("#")[0].trim()}).filter(function(r){return r.length>0}).join(" ").replace(/\s+/g," ").trim();return e=e.replace(/\b(\d+)\b/g,function(r,n){var i=parseInt(n);if(i>=1&&i<=16)return"OP_"+i;if(i===0)return"OP_0";if(i===-1)return"OP_1NEGATE";var o=i,c=o<0;c&&(o=-o);for(var h=[];o>0;)h.push(o&255),o=Math.floor(o/256);return h.length===0&&h.push(0),c?h[h.length-1]>=128?h.push(128):h[h.length-1]|=128:h.length>0&&h[h.length-1]>=128&&h.push(0),E.Buffer.from(h).toString("hex")}),e};ce.prototype._analyzeConstraints=function(t,e){var r={};try{var n=Xe();if(e.minimumAmount) ...
8\u{1F4CA} Categories:`),kn.getCategories().forEach(e=>{let r=Object.values(Ue).filter(n=>n.category===e).length;console.log(` ${e}: ${r} opcodes`)}),console.log(`
9\u{1F9EA} Example: Stack manipulation simulation`);try{let e=["OP_1","OP_2","OP_ADD","OP_3","OP_EQUAL"],r=kn.simulate(e);console.log("Operations:",e.join(" ")),console.log("Final stack:",r.finalStack),console.log("Expected: ['01'] (true, since 1+2=3)"),console.log(`
10\u{1F4DD} Step-by-step execution:`),r.history.forEach(n=>{console.log(` ${n.step}. ${n.opcode}: ${n.description}`),console.log(` Stack: [${n.beforeStack.join(", ")}] \u2192 [${n.afterStack.join(", ")}]`)})}catch(e){console.log("\u274C Simulation error:",e.message)}console.log(`
11\u{1F3AF} Example: Covenant template generation`);let t=kn.generateCovenantTemplate("value","50c3000000000000");console.log("Generated ASM:",t.asm),console.log("Description:",t.description)}});var Bo=Z((mm,To)=>{"use strict";I();var{opcodeMap:Po,scriptNum:rc,utils:dl}=Io(),pr=class{constructor(){this.operations=[],this.comments=[]}comment(e){return this.comments.push(`// ${e}`),this}push(e){if(typeof e=="number")if(e>=-1&&e<=16)e===-1?this.operations.push("OP_1NEGATE"):e===0?this.operations.push("OP_0"):this.operations.push(`OP_${e}`);else{let r=rc.encode(e);this.operations.push(r.toString("he ...
12\u{1F4CA} Example 1: Value Lock Covenant`);let e=nc.valueLock("50c3000000000000").build();console.log("ASM:",e.cleanedASM),console.log("Size:",e.size,"operations"),console.log(`
13\u{1F4CA} Example 2: Custom Arithmetic Covenant`);let r=new pr().comment("Validate that value field equals 5 + 3").extractField("value").push(5).push(3).add().numEqual().verify().push(1),n=r.build();console.log("Operations:",n.operations.length),console.log("ASM:",n.cleanedASM),console.log(`
14\u{1F4CA} Example 3: Documentation Generation`);let i=r.document();console.log("Structure analysis:",i.structure),console.log("Comments:"),i.comments.forEach(o=>console.log(" "+o))}});var cc=Z((xm,ac)=>{"use strict";I();var Pe=de();function Lr(t){if(E.Buffer.isBuffer(t))return Pe.Script.fromBuffer(t).toASM();if(t&&typeof t.toASM=="function")return t.toASM();throw new Error("Input must be a Buffer or Script object")}function pl(t){try{return Pe.Script.fromASM(t)}catch(e){throw new Error(`Invalid ASM string: ${e.message}`)}}function ml(t){try{return Pe.Script.fromASM(t).toBuffer().toString("hex ...
15`),console.log("\u{1F510} Locking Script:",t),console.log("\u{1F513} Unlocking Script:",e),console.log("-------------------------------------------");try{let r=Te.Script.fromHex(t),n=Te.Script.fromHex(e),i=Te.Script.fromBuffer(E.Buffer.concat([n.toBuffer(),r.toBuffer()])),o=new Te.Script.Interpreter,c=new Te.Transaction,h=new Te.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:Te.Script.empty()});c.addInput(h),c.addOutput(new Te.Transaction.Output({satoshis:1e5,script:r}));let d=i.chunks,x=new Te.Script.Interpreter;x.script=i,x.tx=c,x.nIn=0,x.flags=
16\u{1F9E9} Step ${A+1}: ${Te.Opcode.reverseMap[O.opcodenum]||"PUSH"}`),console.log("Stack:",Ln(x.stack)),console.log("AltStack:",Ln(x.altstack))}catch(T){console.log(`\u26A0\uFE0F Error executing opcode ${A+1}:`,T.message);break}}let v=new Te.crypto.BN(1e5),y=o.verify(n,r,c,0,Te.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,v);return console.log(`
17===========================================`),console.log("\u2705 Final Result:",y?"TRUE (Success)":"\u274C FALSE (Failure)"),console.log("Final Stack:",Ln(x.stack||[])),console.log("AltStack:",Ln(x.altstack||[])),console.log("==========================================="),y}catch(r){return console.error("\u274C Error in script execution:",r.message),!1}}if(typeof ve<"u"&&ve.main===ko){N.default.argv.length<4&&(console.log("Usage: node stack_examiner.js <locking_script_hex> <unlocking_script_hex>"),N.default.exit(1));let t=N.default.argv[2],e=N.default.argv[3];hc(t,e)}ko.exports={runScript:hc,b ...
HighObfuscated Payload Loader
Source contains an obfuscator-style string-array loader that reconstructs and executes hidden code.
bsv-smartcontract.min.jsView on unpkg · L1 18`),console.log("Script:",t.toASM()),console.log("-------------------------------------------");for(let c=0;c<i.length;c++){let h=i[c],d=ue.Opcode.reverseMap[h.opcodenum]||"PUSH";r&&o?await new Promise(x=>o.question(`
19[${c+1}/${i.length}] Step (${d}) \u2014 press Enter to execute...`,x)):r&&console.log(`
20[${c+1}/${i.length}] Step (${d})`);try{if(typeof n.step=="function")n.step();else{console.log("\u26A0\uFE0F Step-by-step execution not supported in this BSV version"),console.log("\u{1F4A1} Consider using runFullEvaluation instead");break}console.log(`\u{1F9E9} Executed: ${d}`),Lo(n.stack,n.altstack)}catch(x){console.log(`\u26A0\uFE0F Error executing ${d}: ${x.
21===========================================`),console.log("\u2705 Final Stack State:"),Lo(n.stack||[],n.altstack||[]),console.log("===========================================")}function dc(t,e,r){console.log("==========================================="),console.log("\u{1F50D} SCRIPT INTERPRETER DEBUGGER (FULL RUN)"),console.log(`===========================================
Long lines were clipped for display.