Hi there folks,
I’m a dev attempting tonight to put in writing an execute a really silly bitcoin script.
const bitcoin = require('bitcoinjs-lib'); const NETWORK = bitcoin.networks.regtest; const script = [ bitcoin.script.number.encode(1), bitcoin.script.number.encode(1), bitcoin.opcodes.OP_ADD, bitcoin.script.number.encode(2), bitcoin.opcodes.OP_EQUAL, ]; // Compile the script used within the creation of the P2WSH handle const compiledScript = bitcoin.script.compile(script); console.log('Compiled script:', compiledScript.toString('hex')); // Derive the handle from the script const p2wsh = bitcoin.funds.p2wsh({ redeem: { output: compiledScript, community: NETWORK }, community: NETWORK }); console.log(`The script handle: ${p2wsh.handle}`); // Transaction particulars const TX_HASH = '24fa9287953df68e3aebf53c577eda7ac58f09feb041c4124127a22ca2aafccc'; const TX_INDEX = 0; // Output index const TX_OUTPUT_AMOUNT = 10_000; // Quantity in satoshis, regulate accordingly to your state of affairs const RECEIVER = 'bcrt1q6qzr78af963ztaduu7s4srad6llretjt2u2zet'; // Create a brand new PSBT const txb = new bitcoin.Psbt({ community: NETWORK }); txb.addInput({ hash: TX_HASH, index: TX_INDEX, witnessUtxo: { script: Buffer.from('0020b819f9dfd2e879473f602e4e6b603872dd439e1cdd0d793288d65f41a86ecc3c', 'hex'), // Script from the transaction hex worth: TX_OUTPUT_AMOUNT, // This must be the precise quantity of the UTXO }, witnessScript: compiledScript // This must be offered if the UTXO was locked with a P2WSH }); txb.addOutput({ handle: RECEIVER, worth: TX_OUTPUT_AMOUNT - 2500, // Subtract the specified charge }); // Prepared the PSBT to be signed console.log('PSBT for Bitcoin Core:', txb.toBase64());
When I attempt to signal the PSBT with Core I get this view, anybody is aware of what I’m lacking?
Thanks!
https://preview.redd.it/x5kysuik906d1.jpg?width=1184&format=pjpg&auto=webp&s=0662b718b785d01511a7259b99af28ec7bbbfbff