-
Notifications
You must be signed in to change notification settings - Fork 0
/
poc.js
47 lines (41 loc) · 1.17 KB
/
poc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const Liquid = require('liquidjs-lib');
// Initialize Liquid network
const network = Liquid.Networks.Testnet;
// Create new transaction builder
const txb = new Liquid.TransactionBuilder(network);
// Define inputs
const input1 = {
txid: 'input1_txid',
vout: input1_vout,
scriptPubKey: input1_scriptPubKey,
value: input1_value,
};
const input2 = {
txid: 'input2_txid',
vout: input2_vout,
scriptPubKey: input2_scriptPubKey,
value: input2_value,
};
// Add inputs to the transaction builder
txb.addInput(input1);
txb.addInput(input2);
// Define outputs
const output1 = {
script: Liquid.address.toOutputScript('output1_address', network),
value: output1_value,
};
const output2 = {
script: Liquid.address.toOutputScript('output2_address', network),
value: output2_value,
};
// Add outputs to the transaction builder
txb.addOutput(output1);
txb.addOutput(output2);
// Sign inputs
// You would need to implement the logic for participants to sign their inputs
const input = {
// Finalize the transaction
txb.setVersion(2); // Optional: Set transaction version
const tx = txb.buildIncomplete();
// Print out the transaction hex
console.log(tx.toHex());