-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathtransaction.dart
712 lines (619 loc) · 20 KB
/
transaction.dart
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
import 'dart:typed_data';
import 'package:hex/hex.dart';
import 'payments/index.dart' show PaymentData;
import 'payments/p2pkh.dart' show P2PKH;
import 'payments/p2pk.dart' show P2PK;
import 'payments/p2wpkh.dart' show P2WPKH;
import 'crypto.dart' as bcrypto;
import 'classify.dart';
import 'utils/check_types.dart';
import 'utils/script.dart' as bscript;
import 'utils/constants/op.dart';
import 'utils/varuint.dart' as varuint;
const DEFAULT_SEQUENCE = 0xffffffff;
const SIGHASH_ALL = 0x01;
const SIGHASH_NONE = 0x02;
const SIGHASH_SINGLE = 0x03;
const SIGHASH_ANYONECANPAY = 0x80;
const ADVANCED_TRANSACTION_MARKER = 0x00;
const ADVANCED_TRANSACTION_FLAG = 0x01;
final EMPTY_SCRIPT = Uint8List.fromList([]);
final EMPTY_WITNESS = new List<Uint8List>();
final ZERO = HEX
.decode('0000000000000000000000000000000000000000000000000000000000000000');
final ONE = HEX
.decode('0000000000000000000000000000000000000000000000000000000000000001');
final VALUE_UINT64_MAX = HEX.decode('ffffffffffffffff');
final BLANK_OUTPUT =
new Output(script: EMPTY_SCRIPT, valueBuffer: VALUE_UINT64_MAX);
class Transaction {
int version = 1;
int locktime = 0;
List<Input> ins = [];
List<Output> outs = [];
Transaction();
int addInput(Uint8List hash, int index, [int sequence, Uint8List scriptSig]) {
ins.add(new Input(
hash: hash,
index: index,
sequence: sequence ?? DEFAULT_SEQUENCE,
script: scriptSig ?? EMPTY_SCRIPT,
witness: EMPTY_WITNESS));
return ins.length - 1;
}
int addOutput(Uint8List scriptPubKey, int value) {
outs.add(new Output(script: scriptPubKey, value: value));
return outs.length - 1;
}
bool hasWitnesses() {
var witness = ins.firstWhere(
(input) => input.witness != null && input.witness.length != 0,
orElse: () => null);
return witness != null;
}
setInputScript(int index, Uint8List scriptSig) {
ins[index].script = scriptSig;
}
setWitness(int index, List<Uint8List> witness) {
ins[index].witness = witness;
}
hashForWitnessV0(
int inIndex, Uint8List prevOutScript, int value, int hashType) {
var tbuffer = Uint8List.fromList([]);
var toffset = 0;
// Any changes made to the ByteData will also change the buffer, and vice versa.
// https://api.dart.dev/stable/2.7.1/dart-typed_data/ByteBuffer/asByteData.html
ByteData bytes = tbuffer.buffer.asByteData();
var hashOutputs = ZERO;
var hashPrevouts = ZERO;
var hashSequence = ZERO;
writeSlice(slice) {
tbuffer.setRange(toffset, toffset + slice.length, slice);
toffset += slice.length;
}
writeUInt8(i) {
bytes.setUint8(toffset, i);
toffset++;
}
writeUInt32(i) {
bytes.setUint32(toffset, i, Endian.little);
toffset += 4;
}
writeInt32(i) {
bytes.setInt32(toffset, i, Endian.little);
toffset += 4;
}
writeUInt64(i) {
bytes.setUint64(toffset, i, Endian.little);
toffset += 8;
}
writeVarInt(i) {
varuint.encode(i, tbuffer, toffset);
toffset += varuint.encodingLength(i);
}
writeVarSlice(slice) {
writeVarInt(slice.length);
writeSlice(slice);
}
writeVector(vector) {
writeVarInt(vector.length);
vector.forEach((buf) {
writeVarSlice(buf);
});
}
if ((hashType & SIGHASH_ANYONECANPAY) == 0) {
tbuffer = new Uint8List(36 * this.ins.length);
bytes = tbuffer.buffer.asByteData();
toffset = 0;
ins.forEach((txIn) {
writeSlice(txIn.hash);
writeUInt32(txIn.index);
});
hashPrevouts = bcrypto.hash256(tbuffer);
}
if ((hashType & SIGHASH_ANYONECANPAY) == 0 &&
(hashType & 0x1f) != SIGHASH_SINGLE &&
(hashType & 0x1f) != SIGHASH_NONE) {
tbuffer = new Uint8List(4 * this.ins.length);
bytes = tbuffer.buffer.asByteData();
toffset = 0;
ins.forEach((txIn) {
writeUInt32(txIn.sequence);
});
hashSequence = bcrypto.hash256(tbuffer);
}
if ((hashType & 0x1f) != SIGHASH_SINGLE &&
(hashType & 0x1f) != SIGHASH_NONE) {
var txOutsSize =
outs.fold(0, (sum, output) => sum + 8 + varSliceSize(output.script));
tbuffer = new Uint8List(txOutsSize);
bytes = tbuffer.buffer.asByteData();
toffset = 0;
outs.forEach((txOut) {
writeUInt64(txOut.value);
writeVarSlice(txOut.script);
});
hashOutputs = bcrypto.hash256(tbuffer);
} else if ((hashType & 0x1f) == SIGHASH_SINGLE && inIndex < outs.length) {
// SIGHASH_SINGLE only hash that according output
var output = outs[inIndex];
tbuffer = new Uint8List(8 + varSliceSize(output.script));
bytes = tbuffer.buffer.asByteData();
toffset = 0;
writeUInt64(output.value);
writeVarSlice(output.script);
hashOutputs = bcrypto.hash256(tbuffer);
}
tbuffer = new Uint8List(156 + varSliceSize(prevOutScript));
bytes = tbuffer.buffer.asByteData();
toffset = 0;
var input = ins[inIndex];
writeUInt32(version);
writeSlice(hashPrevouts);
writeSlice(hashSequence);
writeSlice(input.hash);
writeUInt32(input.index);
writeVarSlice(prevOutScript);
writeUInt64(value);
writeUInt32(input.sequence);
writeSlice(hashOutputs);
writeUInt32(this.locktime);
writeUInt32(hashType);
return bcrypto.hash256(tbuffer);
}
hashForSignature(int inIndex, Uint8List prevOutScript, int hashType) {
if (inIndex >= ins.length) return ONE;
// ignore OP_CODESEPARATOR
final ourScript =
bscript.compile(bscript.decompile(prevOutScript).where((x) {
return x != OPS['OP_CODESEPARATOR'];
}).toList());
final txTmp = Transaction.clone(this);
// SIGHASH_NONE: ignore all outputs? (wildcard payee)
if ((hashType & 0x1f) == SIGHASH_NONE) {
txTmp.outs = [];
// ignore sequence numbers (except at inIndex)
for (var i = 0; i < txTmp.ins.length; i++) {
if (i != inIndex) {
txTmp.ins[i].sequence = 0;
}
}
// SIGHASH_SINGLE: ignore all outputs, except at the same index?
} else if ((hashType & 0x1f) == SIGHASH_SINGLE) {
// https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L60
if (inIndex >= outs.length) return ONE;
// truncate outputs after
txTmp.outs.length = inIndex + 1;
// 'blank' outputs before
for (var i = 0; i < inIndex; i++) {
txTmp.outs[i] = BLANK_OUTPUT;
}
// ignore sequence numbers (except at inIndex)
for (var i = 0; i < txTmp.ins.length; i++) {
if (i != inIndex) {
txTmp.ins[i].sequence = 0;
}
}
}
// SIGHASH_ANYONECANPAY: ignore inputs entirely?
if (hashType & SIGHASH_ANYONECANPAY != 0) {
txTmp.ins = [txTmp.ins[inIndex]];
txTmp.ins[0].script = ourScript;
// SIGHASH_ALL: only ignore input scripts
} else {
// 'blank' others input scripts
txTmp.ins.forEach((input) {
input.script = EMPTY_SCRIPT;
});
txTmp.ins[inIndex].script = ourScript;
}
// serialize and hash
final buffer = Uint8List(txTmp.virtualSize() + 4);
buffer.buffer
.asByteData()
.setUint32(buffer.length - 4, hashType, Endian.little);
txTmp._toBuffer(buffer, 0);
return bcrypto.hash256(buffer);
}
_byteLength(_ALLOW_WITNESS) {
var hasWitness = _ALLOW_WITNESS && hasWitnesses();
return (hasWitness ? 10 : 8) +
varuint.encodingLength(ins.length) +
varuint.encodingLength(outs.length) +
ins.fold(0, (sum, input) => sum + 40 + varSliceSize(input.script)) +
outs.fold(0, (sum, output) => sum + 8 + varSliceSize(output.script)) +
(hasWitness
? ins.fold(0, (sum, input) => sum + vectorSize(input.witness))
: 0);
}
int vectorSize(List<Uint8List> someVector) {
var length = someVector.length;
return varuint.encodingLength(length) +
someVector.fold(0, (sum, witness) => sum + varSliceSize(witness));
}
int weight() {
var base = _byteLength(false);
var total = _byteLength(true);
return base * 3 + total;
}
int byteLength() {
return _byteLength(true);
}
int virtualSize() {
return (weight() / 4).ceil();
}
Uint8List toBuffer([Uint8List buffer, int initialOffset]) {
return this._toBuffer(buffer, initialOffset, true);
}
String toHex() {
return HEX.encode(this.toBuffer());
}
bool isCoinbaseHash(buffer) {
isHash256bit(buffer);
for (var i = 0; i < 32; ++i) {
if (buffer[i] != 0) return false;
}
return true;
}
bool isCoinbase() {
return ins.length == 1 && isCoinbaseHash(ins[0].hash);
}
Uint8List getHash() {
// if (isCoinbase()) return Uint8List.fromList(List.generate(32, (i) => 0));
return bcrypto.hash256(_toBuffer(null, null, false));
}
String getId() {
return HEX.encode(getHash().reversed.toList());
}
_toBuffer([Uint8List buffer, initialOffset, bool _ALLOW_WITNESS = false]) {
// _ALLOW_WITNESS is used to separate witness part when calculating tx id
if (buffer == null) buffer = new Uint8List(_byteLength(_ALLOW_WITNESS));
// Any changes made to the ByteData will also change the buffer, and vice versa.
// https://api.dart.dev/stable/2.7.1/dart-typed_data/ByteBuffer/asByteData.html
var bytes = buffer.buffer.asByteData();
var offset = initialOffset ?? 0;
writeSlice(slice) {
buffer.setRange(offset, offset + slice.length, slice);
offset += slice.length;
}
writeUInt8(i) {
bytes.setUint8(offset, i);
offset++;
}
writeUInt32(i) {
bytes.setUint32(offset, i, Endian.little);
offset += 4;
}
writeInt32(i) {
bytes.setInt32(offset, i, Endian.little);
offset += 4;
}
writeUInt64(i) {
bytes.setUint64(offset, i, Endian.little);
offset += 8;
}
writeVarInt(i) {
varuint.encode(i, buffer, offset);
offset += varuint.encodingLength(i);
}
writeVarSlice(slice) {
writeVarInt(slice.length);
writeSlice(slice);
}
writeVector(vector) {
writeVarInt(vector.length);
vector.forEach((buf) {
writeVarSlice(buf);
});
}
// Start writeBuffer
writeInt32(version);
if (_ALLOW_WITNESS && hasWitnesses()) {
writeUInt8(ADVANCED_TRANSACTION_MARKER);
writeUInt8(ADVANCED_TRANSACTION_FLAG);
}
writeVarInt(this.ins.length);
ins.forEach((txIn) {
writeSlice(txIn.hash);
writeUInt32(txIn.index);
writeVarSlice(txIn.script);
writeUInt32(txIn.sequence);
});
writeVarInt(this.outs.length);
outs.forEach((txOut) {
if (txOut.valueBuffer == null) {
writeUInt64(txOut.value);
} else {
writeSlice(txOut.valueBuffer);
}
writeVarSlice(txOut.script);
});
if (_ALLOW_WITNESS && hasWitnesses()) {
ins.forEach((txInt) {
writeVector(txInt.witness);
});
}
writeUInt32(this.locktime);
// End writeBuffer
// avoid slicing unless necessary
if (initialOffset != null) return buffer.sublist(initialOffset, offset);
return buffer;
}
factory Transaction.clone(Transaction _tx) {
Transaction tx = new Transaction();
tx.version = _tx.version;
tx.locktime = _tx.locktime;
tx.ins = _tx.ins.map((input) {
return Input.clone(input);
}).toList();
tx.outs = _tx.outs.map((output) {
return Output.clone(output);
}).toList();
return tx;
}
factory Transaction.fromBuffer(Uint8List buffer) {
var offset = 0;
// Any changes made to the ByteData will also change the buffer, and vice versa.
// https://api.dart.dev/stable/2.7.1/dart-typed_data/ByteBuffer/asByteData.html
ByteData bytes = buffer.buffer.asByteData();
int readUInt8() {
final i = bytes.getUint8(offset);
offset++;
return i;
}
int readUInt32() {
final i = bytes.getUint32(offset, Endian.little);
offset += 4;
return i;
}
int readInt32() {
final i = bytes.getInt32(offset, Endian.little);
offset += 4;
return i;
}
int readUInt64() {
final i = bytes.getUint64(offset, Endian.little);
offset += 8;
return i;
}
Uint8List readSlice(n) {
offset += n;
return buffer.sublist(offset - n, offset);
}
int readVarInt() {
final vi = varuint.decode(buffer, offset);
offset += varuint.encodingLength(vi);
return vi;
}
Uint8List readVarSlice() {
return readSlice(readVarInt());
}
List<Uint8List> readVector() {
var count = readVarInt();
List<Uint8List> vector = [];
for (var i = 0; i < count; ++i) {
vector.add(readVarSlice());
}
return vector;
}
final tx = new Transaction();
tx.version = readInt32();
final marker = readUInt8();
final flag = readUInt8();
var hasWitnesses = false;
if (marker == ADVANCED_TRANSACTION_MARKER &&
flag == ADVANCED_TRANSACTION_FLAG) {
hasWitnesses = true;
} else {
offset -= 2; // Reset offset if not segwit tx
}
final vinLen = readVarInt();
for (var i = 0; i < vinLen; ++i) {
tx.ins.add(new Input(
hash: readSlice(32),
index: readUInt32(),
script: readVarSlice(),
sequence: readUInt32()));
}
final voutLen = readVarInt();
for (var i = 0; i < voutLen; ++i) {
tx.outs.add(new Output(value: readUInt64(), script: readVarSlice()));
}
if (hasWitnesses) {
for (var i = 0; i < vinLen; ++i) {
tx.ins[i].witness = readVector();
}
}
tx.locktime = readUInt32();
if (offset != buffer.length)
throw new ArgumentError('Transaction has unexpected data');
return tx;
}
factory Transaction.fromHex(String hex) {
return Transaction.fromBuffer(HEX.decode(hex));
}
@override
String toString() {
this.ins.forEach((txInput) {
print(txInput.toString());
});
this.outs.forEach((txOutput) {
print(txOutput.toString());
});
}
}
class Input {
Uint8List hash;
int index;
int sequence;
int value;
Uint8List script;
Uint8List signScript;
Uint8List prevOutScript;
String prevOutType;
bool hasWitness;
List<Uint8List> pubkeys;
List<Uint8List> signatures;
List<Uint8List> witness;
Input(
{this.hash,
this.index,
this.script,
this.sequence,
this.value,
this.prevOutScript,
this.pubkeys,
this.signatures,
this.witness,
this.prevOutType}) {
this.hasWitness = false; // Default value
if (this.hash != null && !isHash256bit(this.hash))
throw new ArgumentError('Invalid input hash');
if (this.index != null && !isUint(this.index, 32))
throw new ArgumentError('Invalid input index');
if (this.sequence != null && !isUint(this.sequence, 32))
throw new ArgumentError('Invalid input sequence');
if (this.value != null && !isShatoshi(this.value))
throw ArgumentError('Invalid ouput value');
}
factory Input.expandInput(Uint8List scriptSig, List<Uint8List> witness,
[String type, Uint8List scriptPubKey]) {
if (type == null) {
var ssType = classifyInput(scriptSig);
var wsType = classifyWitness(witness);
if (ssType == SCRIPT_TYPES['NONSTANDARD']) ssType = null;
if (wsType == SCRIPT_TYPES['NONSTANDARD']) wsType = null;
type = ssType ?? wsType;
}
if (type == SCRIPT_TYPES['P2WPKH']) {
P2WPKH p2wpkh = new P2WPKH(data: new PaymentData(witness: witness));
return new Input(
prevOutScript: p2wpkh.data.output,
prevOutType: SCRIPT_TYPES['P2WPKH'],
pubkeys: [p2wpkh.data.pubkey],
signatures: [p2wpkh.data.signature]);
} else if (type == SCRIPT_TYPES['P2PKH']) {
P2PKH p2pkh = new P2PKH(data: new PaymentData(input: scriptSig));
return new Input(
prevOutScript: p2pkh.data.output,
prevOutType: SCRIPT_TYPES['P2PKH'],
pubkeys: [p2pkh.data.pubkey],
signatures: [p2pkh.data.signature]);
} else if (type == SCRIPT_TYPES['P2PK']) {
P2PK p2pk = new P2PK(data: new PaymentData(input: scriptSig));
return new Input(
prevOutType: SCRIPT_TYPES['P2PK'],
pubkeys: [],
signatures: [p2pk.data.signature]);
}
return Input(
prevOutType: SCRIPT_TYPES['NONSTANDARD'],
prevOutScript: scriptSig,
);
}
factory Input.clone(Input input) {
return new Input(
hash: input.hash != null ? Uint8List.fromList(input.hash) : null,
index: input.index,
script: input.script != null ? Uint8List.fromList(input.script) : null,
sequence: input.sequence,
value: input.value,
prevOutScript: input.prevOutScript != null
? Uint8List.fromList(input.prevOutScript)
: null,
pubkeys: input.pubkeys != null
? input.pubkeys.map(
(pubkey) => pubkey != null ? Uint8List.fromList(pubkey) : null)
: null,
signatures: input.signatures != null
? input.signatures.map((signature) =>
signature != null ? Uint8List.fromList(signature) : null)
: null,
);
}
@override
String toString() {
return 'Input{hash: $hash, index: $index, sequence: $sequence, value: $value, script: $script, signScript: $signScript, prevOutScript: $prevOutScript, pubkeys: $pubkeys, signatures: $signatures, witness: $witness, prevOutType: $prevOutType}';
}
}
class Output {
Uint8List script;
int value;
Uint8List valueBuffer;
List<Uint8List> pubkeys;
List<Uint8List> signatures;
Output(
{this.script,
this.value,
this.pubkeys,
this.signatures,
this.valueBuffer}) {
if (value != null && !isShatoshi(value))
throw ArgumentError('Invalid ouput value');
}
factory Output.expandOutput(Uint8List script, [Uint8List ourPubKey]) {
if (ourPubKey == null) return new Output();
var type = classifyOutput(script);
if (type == SCRIPT_TYPES['P2WPKH']) {
Uint8List wpkh1 =
new P2WPKH(data: new PaymentData(output: script)).data.hash;
Uint8List wpkh2 = bcrypto.hash160(ourPubKey);
if (wpkh1 != wpkh2) throw ArgumentError('Hash mismatch!');
return new Output(pubkeys: [ourPubKey], signatures: [null]);
} else if (type == SCRIPT_TYPES['P2PKH']) {
Uint8List pkh1 =
new P2PKH(data: new PaymentData(output: script)).data.hash;
Uint8List pkh2 = bcrypto.hash160(ourPubKey);
if (pkh1 != pkh2) throw ArgumentError('Hash mismatch!');
return new Output(pubkeys: [ourPubKey], signatures: [null]);
}
}
factory Output.clone(Output output) {
return new Output(
script: output.script != null ? Uint8List.fromList(output.script) : null,
value: output.value,
valueBuffer: output.valueBuffer != null
? Uint8List.fromList(output.valueBuffer)
: null,
pubkeys: output.pubkeys != null
? output.pubkeys.map(
(pubkey) => pubkey != null ? Uint8List.fromList(pubkey) : null)
: null,
signatures: output.signatures != null
? output.signatures.map((signature) =>
signature != null ? Uint8List.fromList(signature) : null)
: null,
);
}
@override
String toString() {
return 'Output{script: $script, value: $value, valueBuffer: $valueBuffer, pubkeys: $pubkeys, signatures: $signatures}';
}
}
bool isCoinbaseHash(Uint8List buffer) {
if (!isHash256bit(buffer)) throw new ArgumentError('Invalid hash');
for (var i = 0; i < 32; ++i) {
if (buffer[i] != 0) return false;
}
return true;
}
bool _isP2PKHInput(script) {
final chunks = bscript.decompile(script);
return chunks != null &&
chunks.length == 2 &&
bscript.isCanonicalScriptSignature(chunks[0]) &&
bscript.isCanonicalPubKey(chunks[1]);
}
bool _isP2PKHOutput(script) {
final buffer = bscript.compile(script);
return buffer.length == 25 &&
buffer[0] == OPS['OP_DUP'] &&
buffer[1] == OPS['OP_HASH160'] &&
buffer[2] == 0x14 &&
buffer[23] == OPS['OP_EQUALVERIFY'] &&
buffer[24] == OPS['OP_CHECKSIG'];
}
int varSliceSize(Uint8List someScript) {
final length = someScript.length;
return varuint.encodingLength(length) + length;
}