Closed radicleart closed 1 year ago
import * as btc from './index.js';
import { hex } from '@scure/base';
import { secp256k1 } from '@noble/curves/secp256k1';
const privKey = hex.decode('0101010101010101010101010101010101010101010101010101010101010101');
// Allow unknown outputs
const tx = new btc.Transaction({
allowUnknowOutput: true,
});
tx.addInput({
txid: hex.decode('fae21e319ca827df32462afc3225c17719338a8e8d3e3b3ddeb0c2387da3a4c7'),
index: 0,
witnessUtxo: {
amount: 600n,
script: btc.p2wpkh(secp256k1.getPublicKey(privKey, true)).script,
},
});
// Add unspendable output with 'OP_RETURN'
tx.addOutput({ script: btc.Script.encode(['RETURN']), amount: 0n });
tx.sign(privKey);
tx.finalize();
console.log(tx.extract());
Thank you!
Hi, I'm porting code from bitcoinjs to your library.
In bitcoinjs I can create an unspendable, OP_RETURN, output like this;
Anything you can point me to figure the equivalent here greatly appreciated?