ecash-lib 0.2.0-rc → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -15
- package/dist/{src/ecc.d.ts → ecc.d.ts} +6 -2
- package/dist/ecc.d.ts.map +1 -0
- package/dist/{src/ecc.js → ecc.js} +9 -6
- package/dist/ecc.js.map +1 -0
- package/dist/ffi/ecash_lib_wasm_bg_browser.wasm +0 -0
- package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm +0 -0
- package/dist/ffi/ecash_lib_wasm_bg_nodejs.wasm.d.ts +16 -0
- package/dist/ffi/{ecash_lib_wasm.js → ecash_lib_wasm_browser.js} +1 -1
- package/dist/ffi/ecash_lib_wasm_nodejs.d.ts +50 -0
- package/dist/ffi/ecash_lib_wasm_nodejs.js +265 -0
- package/dist/hash.d.ts +11 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +24 -0
- package/dist/hash.js.map +1 -0
- package/dist/{src/index.d.ts → index.d.ts} +5 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/indexBrowser.d.ts +3 -0
- package/dist/indexBrowser.d.ts.map +1 -0
- package/dist/indexBrowser.js +22 -0
- package/dist/indexBrowser.js.map +1 -0
- package/dist/indexNodeJs.d.ts +3 -0
- package/dist/indexNodeJs.d.ts.map +1 -0
- package/dist/indexNodeJs.js +22 -0
- package/dist/indexNodeJs.js.map +1 -0
- package/dist/initBrowser.d.ts +3 -0
- package/dist/initBrowser.d.ts.map +1 -0
- package/dist/initBrowser.js +44 -0
- package/dist/initBrowser.js.map +1 -0
- package/dist/initNodeJs.d.ts +3 -0
- package/dist/initNodeJs.d.ts.map +1 -0
- package/dist/initNodeJs.js +43 -0
- package/dist/initNodeJs.js.map +1 -0
- package/dist/io/bytes.d.ts.map +1 -0
- package/dist/{src/io → io}/bytes.js +5 -1
- package/dist/io/bytes.js.map +1 -0
- package/dist/io/hex.d.ts.map +1 -0
- package/dist/{src/io → io}/hex.js +11 -4
- package/dist/io/hex.js.map +1 -0
- package/dist/io/int.d.ts.map +1 -0
- package/dist/{src/io → io}/int.js +2 -1
- package/dist/io/int.js.map +1 -0
- package/dist/io/str.d.ts +5 -0
- package/dist/io/str.d.ts.map +1 -0
- package/dist/io/str.js +19 -0
- package/dist/io/str.js.map +1 -0
- package/dist/io/varsize.d.ts.map +1 -0
- package/dist/{src/io → io}/varsize.js +7 -2
- package/dist/io/varsize.js.map +1 -0
- package/dist/io/writer.d.ts.map +1 -0
- package/dist/{src/io → io}/writer.js +2 -1
- package/dist/io/writer.js.map +1 -0
- package/dist/io/writerbytes.d.ts.map +1 -0
- package/dist/{src/io → io}/writerbytes.js +5 -1
- package/dist/io/writerbytes.js.map +1 -0
- package/dist/io/writerlength.d.ts.map +1 -0
- package/dist/{src/io → io}/writerlength.js +5 -1
- package/dist/io/writerlength.js.map +1 -0
- package/dist/op.d.ts.map +1 -0
- package/dist/{src/op.js → op.js} +23 -16
- package/dist/op.js.map +1 -0
- package/dist/opcode.d.ts.map +1 -0
- package/dist/opcode.js +141 -0
- package/dist/opcode.js.map +1 -0
- package/dist/{src/script.d.ts → script.d.ts} +2 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/script.js +196 -0
- package/dist/script.js.map +1 -0
- package/dist/sigHashType.d.ts.map +1 -0
- package/dist/{src/sigHashType.js → sigHashType.js} +23 -19
- package/dist/sigHashType.js.map +1 -0
- package/dist/test/testRunner.d.ts +21 -0
- package/dist/test/testRunner.d.ts.map +1 -0
- package/dist/test/testRunner.js +171 -0
- package/dist/test/testRunner.js.map +1 -0
- package/dist/token/alp.d.ts.map +1 -0
- package/dist/token/alp.js +117 -0
- package/dist/token/alp.js.map +1 -0
- package/dist/{src/token → token}/common.d.ts +4 -0
- package/dist/token/common.d.ts.map +1 -0
- package/dist/token/common.js +12 -0
- package/dist/token/common.js.map +1 -0
- package/dist/token/empp.d.ts.map +1 -0
- package/dist/{src/token → token}/empp.js +13 -9
- package/dist/token/empp.js.map +1 -0
- package/dist/token/slp.d.ts +35 -0
- package/dist/token/slp.d.ts.map +1 -0
- package/dist/token/slp.js +172 -0
- package/dist/token/slp.js.map +1 -0
- package/dist/{src/tx.d.ts → tx.d.ts} +4 -0
- package/dist/tx.d.ts.map +1 -0
- package/dist/{src/tx.js → tx.js} +40 -20
- package/dist/tx.js.map +1 -0
- package/dist/txBuilder.d.ts.map +1 -0
- package/dist/{src/txBuilder.js → txBuilder.js} +36 -25
- package/dist/txBuilder.js.map +1 -0
- package/dist/unsignedTx.d.ts.map +1 -0
- package/dist/{src/unsignedTx.js → unsignedTx.js} +34 -29
- package/dist/unsignedTx.js.map +1 -0
- package/package.json +7 -4
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +4 -7
- package/.nyc_output/0fc40ca6-d52c-45eb-b31b-2601ce70b887.json +0 -1
- package/.nyc_output/ac5be6db-4e40-41f8-8b84-7598d4747e57.json +0 -1
- package/.nyc_output/b316d46f-5ea0-4e98-884a-bfbf9cc1d0f8.json +0 -1
- package/.nyc_output/f965566b-9422-4874-b45e-9eefda9c769c.json +0 -1
- package/.nyc_output/processinfo/0fc40ca6-d52c-45eb-b31b-2601ce70b887.json +0 -1
- package/.nyc_output/processinfo/ac5be6db-4e40-41f8-8b84-7598d4747e57.json +0 -1
- package/.nyc_output/processinfo/b316d46f-5ea0-4e98-884a-bfbf9cc1d0f8.json +0 -1
- package/.nyc_output/processinfo/f965566b-9422-4874-b45e-9eefda9c769c.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/dist/ffi/ecash_lib_wasm_bg.wasm +0 -0
- package/dist/src/ecc.d.ts.map +0 -1
- package/dist/src/ecc.js.map +0 -1
- package/dist/src/hash.d.ts +0 -5
- package/dist/src/hash.d.ts.map +0 -1
- package/dist/src/hash.js +0 -8
- package/dist/src/hash.js.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -21
- package/dist/src/index.js.map +0 -1
- package/dist/src/init.d.ts +0 -3
- package/dist/src/init.d.ts.map +0 -1
- package/dist/src/init.js +0 -18
- package/dist/src/init.js.map +0 -1
- package/dist/src/io/bytes.d.ts.map +0 -1
- package/dist/src/io/bytes.js.map +0 -1
- package/dist/src/io/hex.d.ts.map +0 -1
- package/dist/src/io/hex.js.map +0 -1
- package/dist/src/io/int.d.ts.map +0 -1
- package/dist/src/io/int.js.map +0 -1
- package/dist/src/io/str.d.ts +0 -3
- package/dist/src/io/str.d.ts.map +0 -1
- package/dist/src/io/str.js +0 -9
- package/dist/src/io/str.js.map +0 -1
- package/dist/src/io/varsize.d.ts.map +0 -1
- package/dist/src/io/varsize.js.map +0 -1
- package/dist/src/io/writer.d.ts.map +0 -1
- package/dist/src/io/writer.js.map +0 -1
- package/dist/src/io/writerbytes.d.ts.map +0 -1
- package/dist/src/io/writerbytes.js.map +0 -1
- package/dist/src/io/writerlength.d.ts.map +0 -1
- package/dist/src/io/writerlength.js.map +0 -1
- package/dist/src/op.d.ts.map +0 -1
- package/dist/src/op.js.map +0 -1
- package/dist/src/opcode.d.ts.map +0 -1
- package/dist/src/opcode.js +0 -136
- package/dist/src/opcode.js.map +0 -1
- package/dist/src/script.d.ts.map +0 -1
- package/dist/src/script.js +0 -132
- package/dist/src/script.js.map +0 -1
- package/dist/src/sigHashType.d.ts.map +0 -1
- package/dist/src/sigHashType.js.map +0 -1
- package/dist/src/token/alp.d.ts.map +0 -1
- package/dist/src/token/alp.js +0 -110
- package/dist/src/token/alp.js.map +0 -1
- package/dist/src/token/common.d.ts.map +0 -1
- package/dist/src/token/common.js +0 -9
- package/dist/src/token/common.js.map +0 -1
- package/dist/src/token/empp.d.ts.map +0 -1
- package/dist/src/token/empp.js.map +0 -1
- package/dist/src/tx.d.ts.map +0 -1
- package/dist/src/tx.js.map +0 -1
- package/dist/src/txBuilder.d.ts.map +0 -1
- package/dist/src/txBuilder.js.map +0 -1
- package/dist/src/unsignedTx.d.ts.map +0 -1
- package/dist/src/unsignedTx.js.map +0 -1
- package/tests/alp.test.ts +0 -515
- package/tests/txBuilder.test.ts +0 -680
- /package/dist/ffi/{ecash_lib_wasm_bg.wasm.d.ts → ecash_lib_wasm_bg_browser.wasm.d.ts} +0 -0
- /package/dist/ffi/{ecash_lib_wasm.d.ts → ecash_lib_wasm_browser.d.ts} +0 -0
- /package/dist/{src/io → io}/bytes.d.ts +0 -0
- /package/dist/{src/io → io}/hex.d.ts +0 -0
- /package/dist/{src/io → io}/int.d.ts +0 -0
- /package/dist/{src/io → io}/varsize.d.ts +0 -0
- /package/dist/{src/io → io}/writer.d.ts +0 -0
- /package/dist/{src/io → io}/writerbytes.d.ts +0 -0
- /package/dist/{src/io → io}/writerlength.d.ts +0 -0
- /package/dist/{src/op.d.ts → op.d.ts} +0 -0
- /package/dist/{src/opcode.d.ts → opcode.d.ts} +0 -0
- /package/dist/{src/sigHashType.d.ts → sigHashType.d.ts} +0 -0
- /package/dist/{src/token → token}/alp.d.ts +0 -0
- /package/dist/{src/token → token}/empp.d.ts +0 -0
- /package/dist/{src/txBuilder.d.ts → txBuilder.d.ts} +0 -0
- /package/dist/{src/unsignedTx.d.ts → unsignedTx.d.ts} +0 -0
package/tests/alp.test.ts
DELETED
|
@@ -1,515 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024 The Bitcoin developers
|
|
2
|
-
// Distributed under the MIT software license, see the accompanying
|
|
3
|
-
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
-
|
|
5
|
-
import { expect, use } from 'chai';
|
|
6
|
-
import { ChildProcess, spawn } from 'node:child_process';
|
|
7
|
-
import { EventEmitter, once } from 'node:events';
|
|
8
|
-
|
|
9
|
-
import { ChronikClientNode } from 'chronik-client';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
ALL_BIP143,
|
|
13
|
-
Ecc,
|
|
14
|
-
EccWasm,
|
|
15
|
-
OP_1,
|
|
16
|
-
OP_RETURN,
|
|
17
|
-
OutPoint,
|
|
18
|
-
P2PKHSignatory,
|
|
19
|
-
Script,
|
|
20
|
-
Tx,
|
|
21
|
-
TxBuilder,
|
|
22
|
-
fromHex,
|
|
23
|
-
initWasm,
|
|
24
|
-
pushBytesOp,
|
|
25
|
-
shaRmd160,
|
|
26
|
-
toHex,
|
|
27
|
-
} from '../src/index.js';
|
|
28
|
-
import { emppScript } from '../src/token/empp.js';
|
|
29
|
-
import {
|
|
30
|
-
ALP_STANDARD,
|
|
31
|
-
alpGenesis,
|
|
32
|
-
alpMint,
|
|
33
|
-
alpSend,
|
|
34
|
-
} from '../src/token/alp.js';
|
|
35
|
-
|
|
36
|
-
const NUM_COINS = 500;
|
|
37
|
-
const COIN_VALUE = 100000;
|
|
38
|
-
const OP_TRUE_SCRIPT = Script.fromOps([OP_1]);
|
|
39
|
-
const OP_TRUE_SCRIPT_SIG = Script.fromOps([
|
|
40
|
-
pushBytesOp(OP_TRUE_SCRIPT.bytecode),
|
|
41
|
-
]);
|
|
42
|
-
// Like OP_TRUE_SCRIPT but much bigger to avoid undersize
|
|
43
|
-
const ANYONE_SCRIPT = Script.fromOps([pushBytesOp(fromHex('01'.repeat(100)))]);
|
|
44
|
-
const ANYONE_SCRIPT_SIG = Script.fromOps([pushBytesOp(ANYONE_SCRIPT.bytecode)]);
|
|
45
|
-
|
|
46
|
-
const ALP_TOKEN_TYPE_STANDARD = {
|
|
47
|
-
number: 0,
|
|
48
|
-
protocol: 'ALP',
|
|
49
|
-
type: 'ALP_TOKEN_TYPE_STANDARD',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
describe('TxBuilder', () => {
|
|
53
|
-
let testRunner: ChildProcess;
|
|
54
|
-
let chronik: ChronikClientNode;
|
|
55
|
-
let ecc: Ecc;
|
|
56
|
-
let coinsTxid: string;
|
|
57
|
-
let outputIdx: number = 0;
|
|
58
|
-
|
|
59
|
-
function getOutpoint(): OutPoint {
|
|
60
|
-
return {
|
|
61
|
-
txid: coinsTxid,
|
|
62
|
-
outIdx: outputIdx++, // use value, then increment
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function sendToScript(
|
|
67
|
-
value: number,
|
|
68
|
-
script: Script,
|
|
69
|
-
): Promise<string> {
|
|
70
|
-
const setupTx = new Tx({
|
|
71
|
-
inputs: [
|
|
72
|
-
{
|
|
73
|
-
prevOut: getOutpoint(),
|
|
74
|
-
script: ANYONE_SCRIPT_SIG,
|
|
75
|
-
sequence: 0xffffffff,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
outputs: [{ value, script }],
|
|
79
|
-
});
|
|
80
|
-
return (await chronik.broadcastTx(setupTx.ser())).txid;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
before(async () => {
|
|
84
|
-
const statusEvent = new EventEmitter();
|
|
85
|
-
|
|
86
|
-
testRunner = spawn(
|
|
87
|
-
'python3',
|
|
88
|
-
[
|
|
89
|
-
'test/functional/test_runner.py',
|
|
90
|
-
// Place the setup in the python file
|
|
91
|
-
'setup_scripts/ecash-lib_base',
|
|
92
|
-
],
|
|
93
|
-
{
|
|
94
|
-
stdio: ['ipc'],
|
|
95
|
-
// Needs to be set dynamically and the Bitcoin ABC
|
|
96
|
-
// node has to be built first.
|
|
97
|
-
cwd: process.env.BUILD_DIR || '.',
|
|
98
|
-
},
|
|
99
|
-
);
|
|
100
|
-
// Redirect stdout so we can see the messages from the test runner
|
|
101
|
-
testRunner?.stdout?.pipe(process.stdout);
|
|
102
|
-
|
|
103
|
-
testRunner.on('error', function (error) {
|
|
104
|
-
console.log('Test runner error, aborting: ' + error);
|
|
105
|
-
testRunner.kill();
|
|
106
|
-
process.exit(-1);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
testRunner.on('exit', function (code, signal) {
|
|
110
|
-
// The test runner failed, make sure to propagate the error
|
|
111
|
-
if (code !== null && code !== undefined && code != 0) {
|
|
112
|
-
console.log('Test runner completed with code ' + code);
|
|
113
|
-
process.exit(code);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// The test runner was aborted by a signal, make sure to return an
|
|
117
|
-
// error
|
|
118
|
-
if (signal !== null && signal !== undefined) {
|
|
119
|
-
console.log('Test runner aborted by signal ' + signal);
|
|
120
|
-
process.exit(-2);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// In all other cases, let the test return its own status as
|
|
124
|
-
// expected
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
testRunner.on('spawn', function () {
|
|
128
|
-
console.log('Test runner started');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
testRunner.on('message', function (message: any) {
|
|
132
|
-
if (message && message.test_info && message.test_info.chronik) {
|
|
133
|
-
console.log(
|
|
134
|
-
'Setting chronik url to ',
|
|
135
|
-
message.test_info.chronik,
|
|
136
|
-
);
|
|
137
|
-
chronik = new ChronikClientNode(message.test_info.chronik);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (message && message.status) {
|
|
141
|
-
statusEvent.emit(message.status);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
// Can't use `fetch` for local file so we have to read it using `fs`
|
|
146
|
-
await initWasm();
|
|
147
|
-
ecc = new EccWasm();
|
|
148
|
-
|
|
149
|
-
// We got the coins, can fan out now
|
|
150
|
-
await once(statusEvent, 'ready');
|
|
151
|
-
|
|
152
|
-
const opTrueScriptHash = shaRmd160(OP_TRUE_SCRIPT.bytecode);
|
|
153
|
-
const utxo = (
|
|
154
|
-
await chronik.script('p2sh', toHex(opTrueScriptHash)).utxos()
|
|
155
|
-
).utxos[0];
|
|
156
|
-
const anyoneScriptHash = shaRmd160(ANYONE_SCRIPT.bytecode);
|
|
157
|
-
const anyoneP2sh = Script.p2sh(anyoneScriptHash);
|
|
158
|
-
const tx = new Tx({
|
|
159
|
-
inputs: [
|
|
160
|
-
{
|
|
161
|
-
prevOut: utxo.outpoint,
|
|
162
|
-
script: OP_TRUE_SCRIPT_SIG,
|
|
163
|
-
sequence: 0xffffffff,
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
});
|
|
167
|
-
for (let i = 0; i < NUM_COINS; ++i) {
|
|
168
|
-
tx.outputs.push({
|
|
169
|
-
value: COIN_VALUE,
|
|
170
|
-
script: anyoneP2sh,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
tx.outputs.push({
|
|
174
|
-
value: 0,
|
|
175
|
-
script: Script.fromOps([OP_RETURN]),
|
|
176
|
-
});
|
|
177
|
-
tx.outputs[tx.outputs.length - 1].value =
|
|
178
|
-
utxo.value - NUM_COINS * COIN_VALUE - tx.serSize();
|
|
179
|
-
|
|
180
|
-
coinsTxid = (await chronik.broadcastTx(tx.ser())).txid;
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
after(() => {
|
|
184
|
-
testRunner.send('stop');
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('TxBuilder P2PKH ALP', async () => {
|
|
188
|
-
const sk1 = fromHex('11'.repeat(32));
|
|
189
|
-
const pk1 = ecc.derivePubkey(sk1);
|
|
190
|
-
const pkh1 = shaRmd160(pk1);
|
|
191
|
-
const p2pkh1 = Script.p2pkh(pkh1);
|
|
192
|
-
|
|
193
|
-
const sk2 = fromHex('22'.repeat(32));
|
|
194
|
-
const pk2 = ecc.derivePubkey(sk2);
|
|
195
|
-
const pkh2 = shaRmd160(pk2);
|
|
196
|
-
const p2pkh2 = Script.p2pkh(pkh2);
|
|
197
|
-
|
|
198
|
-
const sk3 = fromHex('33'.repeat(32));
|
|
199
|
-
const pk3 = ecc.derivePubkey(sk3);
|
|
200
|
-
const pkh3 = shaRmd160(pk3);
|
|
201
|
-
const p2pkh3 = Script.p2pkh(pkh3);
|
|
202
|
-
|
|
203
|
-
const sk4 = fromHex('44'.repeat(32));
|
|
204
|
-
const pk4 = ecc.derivePubkey(sk4);
|
|
205
|
-
const pkh4 = shaRmd160(pk4);
|
|
206
|
-
const p2pkh4 = Script.p2pkh(pkh4);
|
|
207
|
-
|
|
208
|
-
await sendToScript(50000, p2pkh1);
|
|
209
|
-
|
|
210
|
-
const utxos = await chronik.script('p2pkh', toHex(pkh1)).utxos();
|
|
211
|
-
expect(utxos.utxos.length).to.equal(1);
|
|
212
|
-
const utxo = utxos.utxos[0];
|
|
213
|
-
|
|
214
|
-
const txBuildGenesis = new TxBuilder({
|
|
215
|
-
inputs: [
|
|
216
|
-
{
|
|
217
|
-
input: {
|
|
218
|
-
prevOut: utxo.outpoint,
|
|
219
|
-
signData: {
|
|
220
|
-
value: utxo.value,
|
|
221
|
-
outputScript: p2pkh1,
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
signatory: P2PKHSignatory(sk1, pk1, ALL_BIP143),
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
outputs: [
|
|
228
|
-
{
|
|
229
|
-
value: 0,
|
|
230
|
-
script: emppScript([
|
|
231
|
-
alpGenesis(
|
|
232
|
-
ALP_STANDARD,
|
|
233
|
-
{
|
|
234
|
-
tokenTicker: 'ALP TOKEN',
|
|
235
|
-
tokenName: 'ALP Token Name',
|
|
236
|
-
url: 'https://example.com',
|
|
237
|
-
data: fromHex('01020304'),
|
|
238
|
-
authPubkey: '03040506',
|
|
239
|
-
decimals: 4,
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
amounts: [2000, 2],
|
|
243
|
-
numBatons: 1,
|
|
244
|
-
},
|
|
245
|
-
),
|
|
246
|
-
]),
|
|
247
|
-
},
|
|
248
|
-
{ value: 10000, script: p2pkh2 },
|
|
249
|
-
{ value: 10000, script: p2pkh1 },
|
|
250
|
-
{ value: 10000, script: p2pkh1 },
|
|
251
|
-
],
|
|
252
|
-
});
|
|
253
|
-
const genesisTx = txBuildGenesis.sign(ecc);
|
|
254
|
-
const genesisTxid = (await chronik.broadcastTx(genesisTx.ser())).txid;
|
|
255
|
-
const tokenId = genesisTxid;
|
|
256
|
-
|
|
257
|
-
expect(await chronik.token(genesisTxid)).to.deep.equal({
|
|
258
|
-
tokenId,
|
|
259
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
260
|
-
genesisInfo: {
|
|
261
|
-
tokenTicker: 'ALP TOKEN',
|
|
262
|
-
tokenName: 'ALP Token Name',
|
|
263
|
-
url: 'https://example.com',
|
|
264
|
-
data: fromHex('01020304'),
|
|
265
|
-
authPubkey: '03040506',
|
|
266
|
-
decimals: 4,
|
|
267
|
-
},
|
|
268
|
-
timeFirstSeen: 1300000000,
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
const utxos2 = await chronik.script('p2pkh', toHex(pkh2)).utxos();
|
|
272
|
-
expect(utxos2.utxos).to.deep.equal([
|
|
273
|
-
{
|
|
274
|
-
outpoint: {
|
|
275
|
-
txid: genesisTxid,
|
|
276
|
-
outIdx: 1,
|
|
277
|
-
},
|
|
278
|
-
blockHeight: -1,
|
|
279
|
-
isCoinbase: false,
|
|
280
|
-
value: 10000,
|
|
281
|
-
isFinal: false,
|
|
282
|
-
token: {
|
|
283
|
-
amount: '2000',
|
|
284
|
-
isMintBaton: false,
|
|
285
|
-
tokenId: tokenId,
|
|
286
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
]);
|
|
290
|
-
|
|
291
|
-
const txBuildMint = new TxBuilder({
|
|
292
|
-
inputs: [
|
|
293
|
-
{
|
|
294
|
-
input: {
|
|
295
|
-
prevOut: {
|
|
296
|
-
txid: genesisTxid,
|
|
297
|
-
outIdx: 3,
|
|
298
|
-
},
|
|
299
|
-
signData: {
|
|
300
|
-
value: 10000,
|
|
301
|
-
outputScript: p2pkh1,
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
signatory: P2PKHSignatory(sk1, pk1, ALL_BIP143),
|
|
305
|
-
},
|
|
306
|
-
],
|
|
307
|
-
outputs: [
|
|
308
|
-
{
|
|
309
|
-
value: 0,
|
|
310
|
-
script: emppScript([
|
|
311
|
-
alpMint(tokenId, ALP_STANDARD, {
|
|
312
|
-
amounts: [500],
|
|
313
|
-
numBatons: 1,
|
|
314
|
-
}),
|
|
315
|
-
]),
|
|
316
|
-
},
|
|
317
|
-
{ value: 546, script: p2pkh1 },
|
|
318
|
-
{ value: 546, script: p2pkh3 },
|
|
319
|
-
],
|
|
320
|
-
});
|
|
321
|
-
const mintTx = txBuildMint.sign(ecc);
|
|
322
|
-
const mintTxid = (await chronik.broadcastTx(mintTx.ser())).txid;
|
|
323
|
-
|
|
324
|
-
const utxos3 = await chronik.script('p2pkh', toHex(pkh3)).utxos();
|
|
325
|
-
expect(utxos3.utxos).to.deep.equal([
|
|
326
|
-
{
|
|
327
|
-
outpoint: {
|
|
328
|
-
txid: mintTxid,
|
|
329
|
-
outIdx: 2,
|
|
330
|
-
},
|
|
331
|
-
blockHeight: -1,
|
|
332
|
-
isCoinbase: false,
|
|
333
|
-
value: 546,
|
|
334
|
-
isFinal: false,
|
|
335
|
-
token: {
|
|
336
|
-
amount: '0',
|
|
337
|
-
isMintBaton: true,
|
|
338
|
-
tokenId: tokenId,
|
|
339
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
]);
|
|
343
|
-
|
|
344
|
-
const txBuildMulti = new TxBuilder({
|
|
345
|
-
inputs: [
|
|
346
|
-
{
|
|
347
|
-
input: {
|
|
348
|
-
prevOut: {
|
|
349
|
-
txid: mintTxid,
|
|
350
|
-
outIdx: 1,
|
|
351
|
-
},
|
|
352
|
-
signData: {
|
|
353
|
-
value: 546,
|
|
354
|
-
outputScript: p2pkh1,
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
signatory: P2PKHSignatory(sk1, pk1, ALL_BIP143),
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
input: {
|
|
361
|
-
prevOut: {
|
|
362
|
-
txid: genesisTxid,
|
|
363
|
-
outIdx: 1,
|
|
364
|
-
},
|
|
365
|
-
signData: {
|
|
366
|
-
value: 10000,
|
|
367
|
-
outputScript: p2pkh2,
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
signatory: P2PKHSignatory(sk2, pk2, ALL_BIP143),
|
|
371
|
-
},
|
|
372
|
-
],
|
|
373
|
-
outputs: [
|
|
374
|
-
{
|
|
375
|
-
value: 0,
|
|
376
|
-
script: emppScript([
|
|
377
|
-
alpGenesis(
|
|
378
|
-
ALP_STANDARD,
|
|
379
|
-
{},
|
|
380
|
-
{
|
|
381
|
-
amounts: [100, 0],
|
|
382
|
-
numBatons: 1,
|
|
383
|
-
},
|
|
384
|
-
),
|
|
385
|
-
// OK to push 01 (not encoded as OP_1)
|
|
386
|
-
fromHex('01'),
|
|
387
|
-
alpSend(tokenId, ALP_STANDARD, [0, 1000, 0, 1500]),
|
|
388
|
-
]),
|
|
389
|
-
},
|
|
390
|
-
{ value: 546, script: p2pkh1 },
|
|
391
|
-
{ value: 546, script: p2pkh2 },
|
|
392
|
-
{ value: 546, script: p2pkh3 },
|
|
393
|
-
{ value: 546, script: p2pkh4 },
|
|
394
|
-
],
|
|
395
|
-
});
|
|
396
|
-
const multiTx = txBuildMulti.sign(ecc);
|
|
397
|
-
const multiTxid = (await chronik.broadcastTx(multiTx.ser())).txid;
|
|
398
|
-
|
|
399
|
-
const multiProtoTx = await chronik.tx(multiTxid);
|
|
400
|
-
expect(multiProtoTx).to.deep.equal({
|
|
401
|
-
txid: multiTxid,
|
|
402
|
-
version: 1,
|
|
403
|
-
inputs: [
|
|
404
|
-
{
|
|
405
|
-
inputScript: toHex(multiTx.inputs[0].script!.bytecode),
|
|
406
|
-
outputScript: toHex(p2pkh1.bytecode),
|
|
407
|
-
prevOut: multiTx.inputs[0].prevOut,
|
|
408
|
-
sequenceNo: 0xffffffff,
|
|
409
|
-
token: {
|
|
410
|
-
amount: '500',
|
|
411
|
-
entryIdx: 1,
|
|
412
|
-
isMintBaton: false,
|
|
413
|
-
tokenId: tokenId,
|
|
414
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
415
|
-
},
|
|
416
|
-
value: 546,
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
inputScript: toHex(multiTx.inputs[1].script!.bytecode),
|
|
420
|
-
outputScript: toHex(p2pkh2.bytecode),
|
|
421
|
-
prevOut: multiTx.inputs[1].prevOut,
|
|
422
|
-
sequenceNo: 0xffffffff,
|
|
423
|
-
token: {
|
|
424
|
-
amount: '2000',
|
|
425
|
-
entryIdx: 1,
|
|
426
|
-
isMintBaton: false,
|
|
427
|
-
tokenId: tokenId,
|
|
428
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
429
|
-
},
|
|
430
|
-
value: 10000,
|
|
431
|
-
},
|
|
432
|
-
],
|
|
433
|
-
outputs: [
|
|
434
|
-
{
|
|
435
|
-
value: 0,
|
|
436
|
-
outputScript: toHex(multiTx.outputs[0].script.bytecode),
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
outputScript: toHex(p2pkh1.bytecode),
|
|
440
|
-
token: {
|
|
441
|
-
amount: '100',
|
|
442
|
-
entryIdx: 0,
|
|
443
|
-
isMintBaton: false,
|
|
444
|
-
tokenId: multiTxid,
|
|
445
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
446
|
-
},
|
|
447
|
-
value: 546,
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
outputScript: toHex(p2pkh2.bytecode),
|
|
451
|
-
token: {
|
|
452
|
-
amount: '1000',
|
|
453
|
-
entryIdx: 1,
|
|
454
|
-
isMintBaton: false,
|
|
455
|
-
tokenId: tokenId,
|
|
456
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
457
|
-
},
|
|
458
|
-
value: 546,
|
|
459
|
-
},
|
|
460
|
-
{
|
|
461
|
-
outputScript: toHex(p2pkh3.bytecode),
|
|
462
|
-
token: {
|
|
463
|
-
amount: '0',
|
|
464
|
-
entryIdx: 0,
|
|
465
|
-
isMintBaton: true,
|
|
466
|
-
tokenId: multiTxid,
|
|
467
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
468
|
-
},
|
|
469
|
-
value: 546,
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
outputScript: toHex(p2pkh4.bytecode),
|
|
473
|
-
token: {
|
|
474
|
-
amount: '1500',
|
|
475
|
-
entryIdx: 1,
|
|
476
|
-
isMintBaton: false,
|
|
477
|
-
tokenId: tokenId,
|
|
478
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
479
|
-
},
|
|
480
|
-
value: 546,
|
|
481
|
-
},
|
|
482
|
-
],
|
|
483
|
-
lockTime: 0,
|
|
484
|
-
timeFirstSeen: 1300000000,
|
|
485
|
-
size: multiTx.serSize(),
|
|
486
|
-
isCoinbase: false,
|
|
487
|
-
tokenEntries: [
|
|
488
|
-
{
|
|
489
|
-
actualBurnAmount: '0',
|
|
490
|
-
burnSummary: '',
|
|
491
|
-
burnsMintBatons: false,
|
|
492
|
-
failedColorings: [],
|
|
493
|
-
intentionalBurn: '0',
|
|
494
|
-
isInvalid: false,
|
|
495
|
-
tokenId: multiTxid,
|
|
496
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
497
|
-
txType: 'GENESIS',
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
actualBurnAmount: '0',
|
|
501
|
-
burnSummary: '',
|
|
502
|
-
burnsMintBatons: false,
|
|
503
|
-
failedColorings: [],
|
|
504
|
-
intentionalBurn: '0',
|
|
505
|
-
isInvalid: false,
|
|
506
|
-
tokenId: tokenId,
|
|
507
|
-
tokenType: ALP_TOKEN_TYPE_STANDARD,
|
|
508
|
-
txType: 'SEND',
|
|
509
|
-
},
|
|
510
|
-
],
|
|
511
|
-
tokenFailedParsings: [],
|
|
512
|
-
tokenStatus: 'TOKEN_STATUS_NORMAL',
|
|
513
|
-
});
|
|
514
|
-
});
|
|
515
|
-
});
|