bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.71k stars 2.11k forks source link

attach "hello world" in transaction using bitcoinjs-lib #2092

Closed yazancash closed 6 months ago

yazancash commented 6 months ago
var txb = new bitcoin.TransactionBuilder(bitcoin.networks.zcash, 0);

txb.setVersion(parseInt(4));
txb.setVersionGroupId(parseInt('0x892f2085', 16));
txb.setLockTime(50000);
txb.setExpiry(0);

var txHash = bitcoin.Buffer.from('a87acacc6945d7755e41590f8ef0aad65ee0e0f9d496177b7ffc90d8da4b8c36', 'hex').reverse();
txb.addInput(txHash,0);

txb.addOutput('t1YUjzMURojUDia99QSQoE7sHSho3faNY7P', 900000);

var keyPair = bitcoin.ECPair.fromWIF(MyPrivateKey, bitcoin.networks.zcash);
txb.sign(0, keyPair, '', 0x03, 1000000);

txb.build().toHex();

how can i include "hello world" text data, or buffer data, in like this transaction ?

junderw commented 6 months ago

We don't support non-Bitcoin networks, and from the looks of your example, zcash has deviated too far from Bitcoin to make this library of any use to your app.

setExpiry and setVersionGroupId are concepts I have never heard of, and TransactionBuilder has been deleted from this library for many many years.