@opcat-labs/opcat 1.0.0 → 1.0.2
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/.cjs2esm.json +18 -0
- package/.mocharc.yaml +1 -1
- package/CHANGELOG.md +13 -0
- package/README.md +6 -0
- package/{lib/address.js → cjs/address.cjs} +77 -72
- package/cjs/block/block.cjs +332 -0
- package/{lib/block/blockheader.js → cjs/block/blockheader.cjs} +8 -7
- package/cjs/block/index.cjs +2 -0
- package/{lib/block/merkleblock.js → cjs/block/merkleblock.cjs} +23 -15
- package/cjs/bn.cjs +3411 -0
- package/{lib/crypto/bn.js → cjs/crypto/bn.cjs} +3 -3
- package/{lib/crypto/ecdsa.js → cjs/crypto/ecdsa.cjs} +150 -14
- package/{lib/crypto/hash.node.js → cjs/crypto/hash.cjs} +13 -2
- package/cjs/crypto/index.cjs +16 -0
- package/{lib/crypto/point.js → cjs/crypto/point.cjs} +11 -4
- package/cjs/crypto/random.cjs +18 -0
- package/{lib/crypto/signature.js → cjs/crypto/signature.cjs} +158 -8
- package/{lib/encoding/base58.js → cjs/encoding/base58.cjs} +58 -2
- package/cjs/encoding/base58check.cjs +192 -0
- package/cjs/encoding/bufferreader.cjs +333 -0
- package/cjs/encoding/bufferwriter.cjs +244 -0
- package/{lib/encoding/decode-asm.js → cjs/encoding/decode-asm.cjs} +4 -4
- package/{lib/encoding/decode-hex.js → cjs/encoding/decode-hex.cjs} +1 -1
- package/cjs/encoding/index.cjs +14 -0
- package/cjs/encoding/varint.cjs +116 -0
- package/{lib/errors/index.js → cjs/errors/index.cjs} +9 -9
- package/{lib/errors/spec.js → cjs/errors/spec.cjs} +2 -2
- package/cjs/hash-cache.cjs +98 -0
- package/{lib/hdprivatekey.js → cjs/hdprivatekey.cjs} +232 -140
- package/{lib/hdpublickey.js → cjs/hdpublickey.cjs} +120 -93
- package/cjs/index.cjs +94 -0
- package/cjs/interpreter/index.cjs +2 -0
- package/cjs/interpreter/interpreter.cjs +1988 -0
- package/{lib/script/stack.js → cjs/interpreter/stack.cjs} +9 -2
- package/{lib/message/message.js → cjs/message/message.cjs} +62 -25
- package/cjs/mnemonic/index.cjs +3 -0
- package/{lib/mnemonic/mnemonic.js → cjs/mnemonic/mnemonic.cjs} +44 -13
- package/{lib/mnemonic/pbkdf2.node.js → cjs/mnemonic/pbkdf2.cjs} +9 -2
- package/cjs/mnemonic/words/index.cjs +66 -0
- package/cjs/network.cjs +13 -0
- package/cjs/networks.cjs +321 -0
- package/{lib/opcode.js → cjs/opcode.cjs} +69 -5
- package/cjs/privatekey.cjs +422 -0
- package/{lib/publickey.js → cjs/publickey.cjs} +14 -16
- package/cjs/script/index.cjs +2 -0
- package/{lib/script/script.js → cjs/script/script.cjs} +322 -67
- package/cjs/transaction/index.cjs +5 -0
- package/cjs/transaction/input/index.cjs +34 -0
- package/cjs/transaction/input/input.cjs +396 -0
- package/{lib/transaction/input/multisig.js → cjs/transaction/input/multisig.cjs} +112 -18
- package/{lib/transaction/input/publickey.js → cjs/transaction/input/publickey.cjs} +29 -19
- package/{lib/transaction/input/publickeyhash.js → cjs/transaction/input/publickeyhash.cjs} +25 -17
- package/{lib/transaction/output.js → cjs/transaction/output.cjs} +100 -15
- package/cjs/transaction/sighash.cjs +187 -0
- package/{lib/transaction/signature.js → cjs/transaction/signature.cjs} +30 -6
- package/cjs/transaction/transaction.cjs +2000 -0
- package/{lib/transaction/unspentoutput.js → cjs/transaction/unspentoutput.cjs} +5 -5
- package/cjs/util/derivation.cjs +53 -0
- package/cjs/util/index.cjs +11 -0
- package/cjs/util/js.cjs +95 -0
- package/{lib/util/preconditions.js → cjs/util/preconditions.cjs} +2 -2
- package/esm/address.js +483 -0
- package/{lib → esm}/block/block.js +82 -27
- package/esm/block/blockheader.js +296 -0
- package/esm/block/index.js +2 -0
- package/esm/block/merkleblock.js +331 -0
- package/esm/bn.js +3411 -0
- package/esm/crypto/bn.js +278 -0
- package/esm/crypto/ecdsa.js +475 -0
- package/{lib/crypto/hash.browser.js → esm/crypto/hash.js} +18 -7
- package/esm/crypto/index.js +16 -0
- package/esm/crypto/point.js +228 -0
- package/esm/crypto/random.js +18 -0
- package/esm/crypto/signature.js +475 -0
- package/esm/encoding/base58.js +167 -0
- package/esm/encoding/base58check.js +192 -0
- package/esm/encoding/bufferreader.js +333 -0
- package/esm/encoding/bufferwriter.js +243 -0
- package/esm/encoding/decode-asm.js +24 -0
- package/esm/encoding/decode-hex.js +32 -0
- package/esm/encoding/decode-script-chunks.js +43 -0
- package/esm/encoding/encode-hex.js +284 -0
- package/esm/encoding/index.js +14 -0
- package/esm/encoding/is-hex.js +7 -0
- package/esm/encoding/varint.js +116 -0
- package/esm/errors/index.js +54 -0
- package/esm/errors/spec.js +314 -0
- package/esm/hash-cache.js +98 -0
- package/esm/hdprivatekey.js +768 -0
- package/esm/hdpublickey.js +549 -0
- package/esm/index.js +66 -0
- package/esm/interpreter/index.js +2 -0
- package/{lib/script → esm/interpreter}/interpreter.js +219 -66
- package/esm/interpreter/stack.js +116 -0
- package/esm/message/message.js +228 -0
- package/esm/mnemonic/index.js +3 -0
- package/esm/mnemonic/mnemonic.js +332 -0
- package/{lib/mnemonic/pbkdf2.browser.js → esm/mnemonic/pbkdf2.js} +13 -6
- package/esm/mnemonic/words/chinese.js +2054 -0
- package/esm/mnemonic/words/english.js +2054 -0
- package/esm/mnemonic/words/french.js +2054 -0
- package/esm/mnemonic/words/index.js +66 -0
- package/esm/mnemonic/words/italian.js +2054 -0
- package/esm/mnemonic/words/japanese.js +2054 -0
- package/esm/mnemonic/words/spanish.js +2054 -0
- package/esm/network.js +13 -0
- package/{lib → esm}/networks.js +61 -120
- package/esm/opcode.js +319 -0
- package/{lib → esm}/privatekey.js +76 -28
- package/esm/publickey.js +384 -0
- package/esm/script/index.js +2 -0
- package/esm/script/script.js +1329 -0
- package/esm/script/write-i32-le.js +17 -0
- package/esm/script/write-push-data.js +35 -0
- package/esm/script/write-u16-le.js +12 -0
- package/esm/script/write-u32-le.js +16 -0
- package/esm/script/write-u64-le.js +24 -0
- package/esm/script/write-u8-le.js +8 -0
- package/esm/script/write-varint.js +46 -0
- package/esm/transaction/index.js +5 -0
- package/esm/transaction/input/index.js +33 -0
- package/{lib → esm}/transaction/input/input.js +132 -90
- package/esm/transaction/input/multisig.js +335 -0
- package/esm/transaction/input/publickey.js +108 -0
- package/esm/transaction/input/publickeyhash.js +124 -0
- package/esm/transaction/output.js +316 -0
- package/{lib → esm}/transaction/sighash.js +42 -22
- package/esm/transaction/signature.js +120 -0
- package/{lib → esm}/transaction/transaction.js +522 -163
- package/esm/transaction/unspentoutput.js +112 -0
- package/esm/util/_.js +47 -0
- package/esm/util/derivation.js +53 -0
- package/esm/util/index.js +12 -0
- package/esm/util/js.js +95 -0
- package/esm/util/preconditions.js +33 -0
- package/fixup.cjs +17 -0
- package/package.json +40 -26
- package/test/{address.js → address.cjs} +14 -43
- package/test/block/{block.js → block.cjs} +3 -5
- package/test/block/{blockheader.js → blockheader.cjs} +2 -2
- package/test/block/{merklebloack.js → merklebloack.cjs} +2 -2
- package/test/crypto/{ecdsa.js → ecdsa.cjs} +9 -9
- package/test/crypto/{hash.browser.js → hash.browser.cjs} +2 -1
- package/test/crypto/{signature.js → signature.cjs} +2 -2
- package/test/data/bitcoind/script_tests.json +5 -5
- package/test/{hashCache.js → hashCache.cjs} +2 -1
- package/test/{hdkeys.js → hdkeys.cjs} +4 -2
- package/test/{hdprivatekey.js → hdprivatekey.cjs} +7 -6
- package/test/{hdpublickey.js → hdpublickey.cjs} +2 -7
- package/test/mnemonic/{pbkdf2.test.js → pbkdf2.test.cjs} +2 -2
- package/test/{networks.js → networks.cjs} +12 -31
- package/test/{publickey.js → publickey.cjs} +2 -2
- package/test/script/{interpreter.js → interpreter.cjs} +5 -5
- package/test/script/{script.js → script.cjs} +8 -2
- package/test/transaction/{deserialize.js → deserialize.cjs} +2 -2
- package/test/transaction/input/{input.js → input.cjs} +1 -1
- package/test/transaction/input/{multisig.js → multisig.cjs} +2 -1
- package/test/transaction/input/{publickeyhash.js → publickeyhash.cjs} +1 -1
- package/test/transaction/{sighash.js → sighash.cjs} +1 -1
- package/test/transaction/{transaction.js → transaction.cjs} +2 -2
- package/tsconfig.json +13 -0
- package/types/address.d.cts +252 -0
- package/types/block/block.d.cts +139 -0
- package/types/block/blockheader.d.cts +125 -0
- package/types/block/index.d.cts +2 -0
- package/types/block/merkleblock.d.cts +95 -0
- package/types/bn.d.cts +202 -0
- package/types/crypto/bn.d.cts +2 -0
- package/types/crypto/ecdsa.d.cts +187 -0
- package/types/crypto/hash.d.cts +118 -0
- package/types/crypto/index.d.cts +7 -0
- package/types/crypto/point.d.cts +134 -0
- package/types/crypto/random.d.cts +13 -0
- package/types/crypto/signature.d.cts +160 -0
- package/types/encoding/base58.d.cts +106 -0
- package/types/encoding/base58check.d.cts +107 -0
- package/types/encoding/bufferreader.d.cts +164 -0
- package/types/encoding/bufferwriter.d.cts +126 -0
- package/types/encoding/decode-asm.d.cts +2 -0
- package/types/encoding/decode-hex.d.cts +2 -0
- package/types/encoding/decode-script-chunks.d.cts +14 -0
- package/types/encoding/encode-hex.d.cts +2 -0
- package/types/encoding/index.d.cts +6 -0
- package/types/encoding/is-hex.d.cts +2 -0
- package/types/encoding/varint.d.cts +66 -0
- package/types/errors/index.d.cts +4 -0
- package/types/errors/spec.d.cts +22 -0
- package/types/hash-cache.d.cts +65 -0
- package/types/hdprivatekey.d.cts +281 -0
- package/types/hdpublickey.d.cts +240 -0
- package/types/index.d.cts +26 -0
- package/types/interpreter/index.d.cts +2 -0
- package/types/interpreter/interpreter.d.cts +228 -0
- package/types/interpreter/stack.d.cts +35 -0
- package/types/message/message.d.cts +110 -0
- package/types/mnemonic/index.d.cts +2 -0
- package/types/mnemonic/mnemonic.d.cts +171 -0
- package/types/mnemonic/pbkdf2.d.cts +14 -0
- package/types/mnemonic/words/chinese.d.cts +2 -0
- package/types/mnemonic/words/english.d.cts +2 -0
- package/types/mnemonic/words/french.d.cts +2 -0
- package/types/mnemonic/words/index.d.cts +22 -0
- package/types/mnemonic/words/italian.d.cts +2 -0
- package/types/mnemonic/words/japanese.d.cts +2 -0
- package/types/mnemonic/words/spanish.d.cts +2 -0
- package/types/network.d.cts +11 -0
- package/types/networks.d.cts +76 -0
- package/types/opcode.d.cts +93 -0
- package/types/privatekey.d.cts +169 -0
- package/types/publickey.d.cts +202 -0
- package/types/script/index.d.cts +2 -0
- package/types/script/script.d.cts +449 -0
- package/types/script/write-i32-le.d.cts +2 -0
- package/types/script/write-push-data.d.cts +2 -0
- package/types/script/write-u16-le.d.cts +2 -0
- package/types/script/write-u32-le.d.cts +2 -0
- package/types/script/write-u64-le.d.cts +2 -0
- package/types/script/write-u8-le.d.cts +2 -0
- package/types/script/write-varint.d.cts +2 -0
- package/types/transaction/index.d.cts +2 -0
- package/types/transaction/input/index.d.cts +2 -0
- package/types/transaction/input/input.d.cts +178 -0
- package/types/transaction/input/multisig.d.cts +127 -0
- package/types/transaction/input/publickey.d.cts +44 -0
- package/types/transaction/input/publickeyhash.d.cts +45 -0
- package/types/transaction/output.d.cts +118 -0
- package/types/transaction/sighash.d.cts +61 -0
- package/types/transaction/signature.d.cts +43 -0
- package/types/transaction/transaction.d.cts +716 -0
- package/types/transaction/unspentoutput.d.cts +83 -0
- package/types/util/_.d.cts +26 -0
- package/types/util/derivation.d.cts +21 -0
- package/types/util/index.d.cts +5 -0
- package/types/util/js.d.cts +50 -0
- package/types/util/preconditions.d.cts +3 -0
- package/index.d.ts +0 -1541
- package/index.js +0 -74
- package/lib/block/index.js +0 -4
- package/lib/bn.js +0 -3423
- package/lib/crypto/hash.js +0 -2
- package/lib/crypto/random.browser.js +0 -28
- package/lib/crypto/random.js +0 -2
- package/lib/crypto/random.node.js +0 -11
- package/lib/encoding/base58check.js +0 -121
- package/lib/encoding/bufferreader.js +0 -212
- package/lib/encoding/bufferwriter.js +0 -140
- package/lib/encoding/varint.js +0 -75
- package/lib/hash-cache.js +0 -50
- package/lib/mnemonic/pbkdf2.js +0 -2
- package/lib/mnemonic/words/index.js +0 -8
- package/lib/script/index.js +0 -5
- package/lib/transaction/index.js +0 -7
- package/lib/transaction/input/index.js +0 -5
- package/lib/util/js.js +0 -90
- /package/{lib/encoding/decode-script-chunks.js → cjs/encoding/decode-script-chunks.cjs} +0 -0
- /package/{lib/encoding/encode-hex.js → cjs/encoding/encode-hex.cjs} +0 -0
- /package/{lib/encoding/is-hex.js → cjs/encoding/is-hex.cjs} +0 -0
- /package/{lib/mnemonic/words/chinese.js → cjs/mnemonic/words/chinese.cjs} +0 -0
- /package/{lib/mnemonic/words/english.js → cjs/mnemonic/words/english.cjs} +0 -0
- /package/{lib/mnemonic/words/french.js → cjs/mnemonic/words/french.cjs} +0 -0
- /package/{lib/mnemonic/words/italian.js → cjs/mnemonic/words/italian.cjs} +0 -0
- /package/{lib/mnemonic/words/japanese.js → cjs/mnemonic/words/japanese.cjs} +0 -0
- /package/{lib/mnemonic/words/spanish.js → cjs/mnemonic/words/spanish.cjs} +0 -0
- /package/{lib/script/write-i32-le.js → cjs/script/write-i32-le.cjs} +0 -0
- /package/{lib/script/write-push-data.js → cjs/script/write-push-data.cjs} +0 -0
- /package/{lib/script/write-u16-le.js → cjs/script/write-u16-le.cjs} +0 -0
- /package/{lib/script/write-u32-le.js → cjs/script/write-u32-le.cjs} +0 -0
- /package/{lib/script/write-u64-le.js → cjs/script/write-u64-le.cjs} +0 -0
- /package/{lib/script/write-u8-le.js → cjs/script/write-u8-le.cjs} +0 -0
- /package/{lib/script/write-varint.js → cjs/script/write-varint.cjs} +0 -0
- /package/{lib/util/_.js → cjs/util/_.cjs} +0 -0
- /package/test/crypto/{bn.js → bn.cjs} +0 -0
- /package/test/crypto/{hash.js → hash.cjs} +0 -0
- /package/test/crypto/{point.js → point.cjs} +0 -0
- /package/test/crypto/{random.js → random.cjs} +0 -0
- /package/test/data/{blk86756-testnet.js → blk86756-testnet.cjs} +0 -0
- /package/test/data/{merkleblocks.js → merkleblocks.cjs} +0 -0
- /package/test/encoding/{base58.js → base58.cjs} +0 -0
- /package/test/encoding/{base58check.js → base58check.cjs} +0 -0
- /package/test/encoding/{bufferreader.js → bufferreader.cjs} +0 -0
- /package/test/encoding/{bufferwriter.js → bufferwriter.cjs} +0 -0
- /package/test/encoding/{varint.js → varint.cjs} +0 -0
- /package/test/{index.js → index.cjs} +0 -0
- /package/test/message/{message.js → message.cjs} +0 -0
- /package/test/mnemonic/{mnemonic.js → mnemonic.cjs} +0 -0
- /package/test/{opcode.js → opcode.cjs} +0 -0
- /package/test/{privatekey.js → privatekey.cjs} +0 -0
- /package/test/transaction/input/{publickey.js → publickey.cjs} +0 -0
- /package/test/transaction/{output.js → output.cjs} +0 -0
- /package/test/transaction/{signature.js → signature.cjs} +0 -0
- /package/test/transaction/{unspentoutput.js → unspentoutput.cjs} +0 -0
- /package/test/util/{js.js → js.cjs} +0 -0
- /package/test/util/{preconditions.js → preconditions.cjs} +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export = Block;
|
|
2
|
+
/**
|
|
3
|
+
* Instantiate a Block from a Buffer, JSON object, or Object with
|
|
4
|
+
* the properties of the Block
|
|
5
|
+
*
|
|
6
|
+
* @param {*} - A Buffer, JSON string, or Object
|
|
7
|
+
* @returns {Block}
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
declare function Block(arg: any): Block;
|
|
11
|
+
declare class Block {
|
|
12
|
+
/**
|
|
13
|
+
* Instantiate a Block from a Buffer, JSON object, or Object with
|
|
14
|
+
* the properties of the Block
|
|
15
|
+
*
|
|
16
|
+
* @param {*} - A Buffer, JSON string, or Object
|
|
17
|
+
* @returns {Block}
|
|
18
|
+
* @constructor
|
|
19
|
+
*/
|
|
20
|
+
constructor(arg: any);
|
|
21
|
+
/**
|
|
22
|
+
* Converts the Block instance to a plain object (also aliased as toJSON).
|
|
23
|
+
* @returns {Object} The plain object representation of the Block.
|
|
24
|
+
*/
|
|
25
|
+
toObject: () => any;
|
|
26
|
+
toJSON(): any;
|
|
27
|
+
/**
|
|
28
|
+
* Converts the block to a buffer representation.
|
|
29
|
+
* @returns {Buffer} The buffer containing the block data.
|
|
30
|
+
*/
|
|
31
|
+
toBuffer(): Buffer;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the string representation of the Block instance.
|
|
34
|
+
* @returns {string} - A hex encoded string of the block
|
|
35
|
+
*/
|
|
36
|
+
toString(): string;
|
|
37
|
+
/**
|
|
38
|
+
* @param {BufferWriter} - An existing instance of BufferWriter
|
|
39
|
+
* @returns {BufferWriter} - An instance of BufferWriter representation of the Block
|
|
40
|
+
*/
|
|
41
|
+
toBufferWriter(bw: any): BufferWriter;
|
|
42
|
+
/**
|
|
43
|
+
* Will iterate through each transaction and return an array of hashes
|
|
44
|
+
* @returns {Array} - An array with transaction hashes
|
|
45
|
+
*/
|
|
46
|
+
getTransactionHashes(): any[];
|
|
47
|
+
/**
|
|
48
|
+
* Will build a merkle tree of all the transactions, ultimately arriving at
|
|
49
|
+
* a single point, the merkle root.
|
|
50
|
+
* @link https://en.bitcoin.it/wiki/Protocol_specification#Merkle_Trees
|
|
51
|
+
* @returns {Array} - An array with each level of the tree after the other.
|
|
52
|
+
*/
|
|
53
|
+
getMerkleTree(): any[];
|
|
54
|
+
/**
|
|
55
|
+
* Calculates the merkleRoot from the transactions.
|
|
56
|
+
* @returns {Buffer} - A buffer of the merkle root hash
|
|
57
|
+
*/
|
|
58
|
+
getMerkleRoot(): Buffer;
|
|
59
|
+
/**
|
|
60
|
+
* Verifies that the transactions in the block match the header merkle root
|
|
61
|
+
* @returns {Boolean} - If the merkle roots match
|
|
62
|
+
*/
|
|
63
|
+
validMerkleRoot(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @returns {Buffer} - The little endian hash buffer of the header
|
|
66
|
+
*/
|
|
67
|
+
_getHash(): Buffer;
|
|
68
|
+
id: any;
|
|
69
|
+
hash: any;
|
|
70
|
+
/**
|
|
71
|
+
* @returns {string} - A string formatted for the console
|
|
72
|
+
*/
|
|
73
|
+
inspect(): string;
|
|
74
|
+
}
|
|
75
|
+
declare namespace Block {
|
|
76
|
+
export let MAX_BLOCK_SIZE: number;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a Block instance from the given argument.
|
|
79
|
+
* @param {*} arg - The input to convert into a Block.
|
|
80
|
+
* @returns {Block} A new Block instance.
|
|
81
|
+
* @throws {TypeError} - If the argument was not recognized
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
export function _from(arg: any): Block;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a Block instance from a plain object.
|
|
87
|
+
* @param {Object} data - The plain object containing block data.
|
|
88
|
+
* @returns {Block} The created Block instance.
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
export function _fromObject(data: any): Block;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a Block instance from a plain JavaScript object.
|
|
94
|
+
* @param {Object} obj - The source object to convert to a Block.
|
|
95
|
+
* @returns {Block} A new Block instance.
|
|
96
|
+
*/
|
|
97
|
+
export function fromObject(obj: any): Block;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a Block instance from a BufferReader.
|
|
100
|
+
* @private
|
|
101
|
+
* @param {BufferReader} br - The buffer reader containing block data
|
|
102
|
+
* @returns {Block} The parsed Block instance
|
|
103
|
+
*/
|
|
104
|
+
export function _fromBufferReader(br: BufferReader): Block;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a Block instance from a BufferReader.
|
|
107
|
+
* @param {BufferReader} br - The buffer reader containing block data.
|
|
108
|
+
* @returns {Block} The parsed Block instance.
|
|
109
|
+
*/
|
|
110
|
+
export function fromBufferReader(br: BufferReader): Block;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a Block instance from a buffer.
|
|
113
|
+
* @param {Buffer} buf - The input buffer to create the block from.
|
|
114
|
+
* @returns {Block} The created Block instance.
|
|
115
|
+
*/
|
|
116
|
+
export function fromBuffer(buf: Buffer): Block;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a Block instance from a string representation.
|
|
119
|
+
* @param {string} str - The string to parse into a Block.
|
|
120
|
+
* @returns {Block} The parsed Block instance.
|
|
121
|
+
*/
|
|
122
|
+
export function fromString(str: string): Block;
|
|
123
|
+
/**
|
|
124
|
+
* Creates a Block instance from raw block data.
|
|
125
|
+
* @param {Object} data - The raw block data to convert.
|
|
126
|
+
* @returns {Block} A new Block instance.
|
|
127
|
+
*/
|
|
128
|
+
export function fromRawBlock(data: any): Block;
|
|
129
|
+
export namespace Values {
|
|
130
|
+
let START_OF_BLOCK: number;
|
|
131
|
+
let NULL_HASH: Buffer;
|
|
132
|
+
}
|
|
133
|
+
export { BlockHeader };
|
|
134
|
+
export { MerkleBlock };
|
|
135
|
+
}
|
|
136
|
+
import BufferWriter = require("../encoding/bufferwriter.cjs");
|
|
137
|
+
import BufferReader = require("../encoding/bufferreader.cjs");
|
|
138
|
+
import BlockHeader = require("./blockheader.cjs");
|
|
139
|
+
import MerkleBlock = require("./merkleblock.cjs");
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export = BlockHeader;
|
|
2
|
+
/**
|
|
3
|
+
* Instantiate a BlockHeader from a Buffer, JSON object, or Object with
|
|
4
|
+
* the properties of the BlockHeader
|
|
5
|
+
*
|
|
6
|
+
* @param {*} - A Buffer, JSON string, or Object
|
|
7
|
+
* @returns {BlockHeader} - An instance of block header
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
declare function BlockHeader(arg: any): BlockHeader;
|
|
11
|
+
declare class BlockHeader {
|
|
12
|
+
/**
|
|
13
|
+
* Instantiate a BlockHeader from a Buffer, JSON object, or Object with
|
|
14
|
+
* the properties of the BlockHeader
|
|
15
|
+
*
|
|
16
|
+
* @param {*} - A Buffer, JSON string, or Object
|
|
17
|
+
* @returns {BlockHeader} - An instance of block header
|
|
18
|
+
* @constructor
|
|
19
|
+
*/
|
|
20
|
+
constructor(arg: any);
|
|
21
|
+
version: any;
|
|
22
|
+
prevHash: any;
|
|
23
|
+
merkleRoot: any;
|
|
24
|
+
time: any;
|
|
25
|
+
timestamp: any;
|
|
26
|
+
bits: any;
|
|
27
|
+
nonce: any;
|
|
28
|
+
/**
|
|
29
|
+
* @returns {Object} - A plain object of the BlockHeader
|
|
30
|
+
*/
|
|
31
|
+
toObject: () => any;
|
|
32
|
+
toJSON(): any;
|
|
33
|
+
/**
|
|
34
|
+
* @returns {Buffer} - A Buffer of the BlockHeader
|
|
35
|
+
*/
|
|
36
|
+
toBuffer(): Buffer;
|
|
37
|
+
/**
|
|
38
|
+
* @returns {string} - A hex encoded string of the BlockHeader
|
|
39
|
+
*/
|
|
40
|
+
toString(): string;
|
|
41
|
+
/**
|
|
42
|
+
* @param {BufferWriter} - An existing instance BufferWriter
|
|
43
|
+
* @returns {BufferWriter} - An instance of BufferWriter representation of the BlockHeader
|
|
44
|
+
*/
|
|
45
|
+
toBufferWriter(bw: any): BufferWriter;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the target difficulty for this block
|
|
48
|
+
* @param {Number} bits
|
|
49
|
+
* @returns {BN} An instance of BN with the decoded difficulty bits
|
|
50
|
+
*/
|
|
51
|
+
getTargetDifficulty(bits: number): BN;
|
|
52
|
+
/**
|
|
53
|
+
* @link https://en.bitcoin.it/wiki/Difficulty
|
|
54
|
+
* @return {Number}
|
|
55
|
+
*/
|
|
56
|
+
getDifficulty(): number;
|
|
57
|
+
private _getHash;
|
|
58
|
+
id: any;
|
|
59
|
+
hash: any;
|
|
60
|
+
/**
|
|
61
|
+
* @returns {Boolean} - If timestamp is not too far in the future
|
|
62
|
+
*/
|
|
63
|
+
validTimestamp(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @returns {Boolean} - If the proof-of-work hash satisfies the target difficulty
|
|
66
|
+
*/
|
|
67
|
+
validProofOfWork(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @returns {string} - A string formatted for the console
|
|
70
|
+
*/
|
|
71
|
+
inspect(): string;
|
|
72
|
+
}
|
|
73
|
+
declare namespace BlockHeader {
|
|
74
|
+
/**
|
|
75
|
+
* @param {*} - A Buffer, JSON string or Object
|
|
76
|
+
* @returns {Object} - An object representing block header data
|
|
77
|
+
* @throws {TypeError} - If the argument was not recognized
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
function _from(arg: any): any;
|
|
81
|
+
/**
|
|
82
|
+
* @param {Object} - A JSON string
|
|
83
|
+
* @returns {Object} - An object representing block header data
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
function _fromObject(data: any): any;
|
|
87
|
+
/**
|
|
88
|
+
* @param {Object} - A plain JavaScript object
|
|
89
|
+
* @returns {BlockHeader} - An instance of block header
|
|
90
|
+
*/
|
|
91
|
+
function fromObject(obj: any): BlockHeader;
|
|
92
|
+
/**
|
|
93
|
+
* @param {Binary} - Raw block binary data or buffer
|
|
94
|
+
* @returns {BlockHeader} - An instance of block header
|
|
95
|
+
*/
|
|
96
|
+
function fromRawBlock(data: any): BlockHeader;
|
|
97
|
+
/**
|
|
98
|
+
* @param {Buffer} - A buffer of the block header
|
|
99
|
+
* @returns {BlockHeader} - An instance of block header
|
|
100
|
+
*/
|
|
101
|
+
function fromBuffer(buf: any): BlockHeader;
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} - A hex encoded buffer of the block header
|
|
104
|
+
* @returns {BlockHeader} - An instance of block header
|
|
105
|
+
*/
|
|
106
|
+
function fromString(str: any): BlockHeader;
|
|
107
|
+
/**
|
|
108
|
+
* @param {BufferReader} - A BufferReader of the block header
|
|
109
|
+
* @returns {Object} - An object representing block header data
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
function _fromBufferReader(br: any): any;
|
|
113
|
+
/**
|
|
114
|
+
* @param {BufferReader} - A BufferReader of the block header
|
|
115
|
+
* @returns {BlockHeader} - An instance of block header
|
|
116
|
+
*/
|
|
117
|
+
function fromBufferReader(br: any): BlockHeader;
|
|
118
|
+
namespace Constants {
|
|
119
|
+
let START_OF_HEADER: number;
|
|
120
|
+
let MAX_TIME_OFFSET: number;
|
|
121
|
+
let LARGEST_HASH: BN;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
import BufferWriter = require("../encoding/bufferwriter.cjs");
|
|
125
|
+
import BN = require("../bn.cjs");
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export = MerkleBlock;
|
|
2
|
+
/**
|
|
3
|
+
* Instantiate a MerkleBlock from a Buffer, JSON object, or Object with
|
|
4
|
+
* the properties of the Block
|
|
5
|
+
*
|
|
6
|
+
* @param {*} - A Buffer, JSON string, or Object representing a MerkleBlock
|
|
7
|
+
* @returns {MerkleBlock}
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
declare function MerkleBlock(arg: any): MerkleBlock;
|
|
11
|
+
declare class MerkleBlock {
|
|
12
|
+
/**
|
|
13
|
+
* Instantiate a MerkleBlock from a Buffer, JSON object, or Object with
|
|
14
|
+
* the properties of the Block
|
|
15
|
+
*
|
|
16
|
+
* @param {*} - A Buffer, JSON string, or Object representing a MerkleBlock
|
|
17
|
+
* @returns {MerkleBlock}
|
|
18
|
+
* @constructor
|
|
19
|
+
*/
|
|
20
|
+
constructor(arg: any);
|
|
21
|
+
_flagBitsUsed: number;
|
|
22
|
+
_hashesUsed: number;
|
|
23
|
+
/**
|
|
24
|
+
* @returns {Buffer} - A buffer of the block
|
|
25
|
+
*/
|
|
26
|
+
toBuffer(): Buffer;
|
|
27
|
+
/**
|
|
28
|
+
* @param {BufferWriter} [bw] - An existing instance of BufferWriter
|
|
29
|
+
* @returns {BufferWriter} - An instance of BufferWriter representation of the MerkleBlock
|
|
30
|
+
*/
|
|
31
|
+
toBufferWriter(bw?: BufferWriter): BufferWriter;
|
|
32
|
+
/**
|
|
33
|
+
* @returns {Object} - A plain object with the MerkleBlock properties
|
|
34
|
+
*/
|
|
35
|
+
toObject: () => any;
|
|
36
|
+
toJSON(): any;
|
|
37
|
+
/**
|
|
38
|
+
* Verify that the MerkleBlock is valid
|
|
39
|
+
* @returns {Boolean} - True/False whether this MerkleBlock is Valid
|
|
40
|
+
*/
|
|
41
|
+
validMerkleTree(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* WARNING: This method is deprecated. Use filteredTxsHash instead.
|
|
44
|
+
*
|
|
45
|
+
* Return a list of all the txs hash that match the filter
|
|
46
|
+
* @returns {Array} - txs hash that match the filter
|
|
47
|
+
*/
|
|
48
|
+
filterdTxsHash(): any[];
|
|
49
|
+
/**
|
|
50
|
+
* Return a list of all the txs hash that match the filter
|
|
51
|
+
* @returns {Array} - txs hash that match the filter
|
|
52
|
+
*/
|
|
53
|
+
filteredTxsHash(): any[];
|
|
54
|
+
private _traverseMerkleTree;
|
|
55
|
+
private _calcTreeWidth;
|
|
56
|
+
private _calcTreeHeight;
|
|
57
|
+
/**
|
|
58
|
+
* @param {Transaction|String} tx - Transaction or Transaction ID Hash
|
|
59
|
+
* @returns {Boolean} - return true/false if this MerkleBlock has the TX or not
|
|
60
|
+
*/
|
|
61
|
+
hasTransaction(tx: Transaction | string): boolean;
|
|
62
|
+
}
|
|
63
|
+
declare namespace MerkleBlock {
|
|
64
|
+
/**
|
|
65
|
+
* @param {Buffer} - MerkleBlock data in a Buffer object
|
|
66
|
+
* @returns {MerkleBlock} - A MerkleBlock object
|
|
67
|
+
*/
|
|
68
|
+
function fromBuffer(buf: any): MerkleBlock;
|
|
69
|
+
/**
|
|
70
|
+
* @param {BufferReader} - MerkleBlock data in a BufferReader object
|
|
71
|
+
* @returns {MerkleBlock} - A MerkleBlock object
|
|
72
|
+
*/
|
|
73
|
+
function fromBufferReader(br: any): MerkleBlock;
|
|
74
|
+
/**
|
|
75
|
+
* Parses a MerkleBlock from a buffer reader.
|
|
76
|
+
* @private
|
|
77
|
+
* @param {BufferReader} br - The buffer reader containing the MerkleBlock data
|
|
78
|
+
* @returns {Object} An object containing:
|
|
79
|
+
* - header {BlockHeader} - The block header
|
|
80
|
+
* - numTransactions {number} - Number of transactions in the block
|
|
81
|
+
* - hashes {string[]} - Array of transaction hashes as hex strings
|
|
82
|
+
* - flags {number[]} - Array of flag bytes
|
|
83
|
+
* @throws {Error} If no merkleblock data is received
|
|
84
|
+
*/
|
|
85
|
+
function _fromBufferReader(br: BufferReader): any;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a MerkleBlock instance from a plain object.
|
|
88
|
+
* @param {Object} obj - The plain object containing MerkleBlock data.
|
|
89
|
+
* @returns {MerkleBlock} A new MerkleBlock instance.
|
|
90
|
+
*/
|
|
91
|
+
function fromObject(obj: any): MerkleBlock;
|
|
92
|
+
}
|
|
93
|
+
import BufferWriter = require("../encoding/bufferwriter.cjs");
|
|
94
|
+
import Transaction = require("../transaction/transaction.cjs");
|
|
95
|
+
import BufferReader = require("../encoding/bufferreader.cjs");
|
package/types/bn.d.cts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
export = BN;
|
|
2
|
+
/**
|
|
3
|
+
* BN (Big Number) constructor.
|
|
4
|
+
* Creates a new BN instance or returns the existing one if input is already a BN.
|
|
5
|
+
* @param {number|BN} number - The number to initialize with (or existing BN instance)
|
|
6
|
+
* @param {number|string} [base=10] - Numeric base (10, 16, etc) or endianness ('le', 'be')
|
|
7
|
+
* @param {string} [endian='be'] - Endianness ('le' for little-endian, 'be' for big-endian)
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
declare function BN(number: number | BN, base?: number | string, endian?: string): number | BN;
|
|
11
|
+
declare class BN {
|
|
12
|
+
/**
|
|
13
|
+
* BN (Big Number) constructor.
|
|
14
|
+
* Creates a new BN instance or returns the existing one if input is already a BN.
|
|
15
|
+
* @param {number|BN} number - The number to initialize with (or existing BN instance)
|
|
16
|
+
* @param {number|string} [base=10] - Numeric base (10, 16, etc) or endianness ('le', 'be')
|
|
17
|
+
* @param {string} [endian='be'] - Endianness ('le' for little-endian, 'be' for big-endian)
|
|
18
|
+
* @constructor
|
|
19
|
+
*/
|
|
20
|
+
constructor(number: number | BN, base?: number | string, endian?: string);
|
|
21
|
+
negative: number;
|
|
22
|
+
words: any[] | number[];
|
|
23
|
+
length: number;
|
|
24
|
+
red: any;
|
|
25
|
+
_init(number: any, base: any, endian: any): void | this;
|
|
26
|
+
private _initNumber;
|
|
27
|
+
_initArray(number: any, base: any, endian: any): this;
|
|
28
|
+
_parseHex(number: any, start: any): void;
|
|
29
|
+
_parseBase(number: any, base: any, start: any): void;
|
|
30
|
+
copy(dest: any): void;
|
|
31
|
+
clone(): BN;
|
|
32
|
+
_expand(size: any): this;
|
|
33
|
+
strip(): this;
|
|
34
|
+
_normSign(): this;
|
|
35
|
+
inspect(): string;
|
|
36
|
+
toString(base: any, padding: any): string;
|
|
37
|
+
toNumber(): any;
|
|
38
|
+
toJSON(): string;
|
|
39
|
+
toBuffer(endian: any, length: any): any;
|
|
40
|
+
toArray(endian: any, length: any): any;
|
|
41
|
+
toArrayLike(ArrayType: any, endian: any, length: any): any;
|
|
42
|
+
_countBits(w: any): number;
|
|
43
|
+
_zeroBits(w: any): number;
|
|
44
|
+
bitLength(): number;
|
|
45
|
+
zeroBits(): number;
|
|
46
|
+
byteLength(): number;
|
|
47
|
+
toTwos(width: any): any;
|
|
48
|
+
fromTwos(width: any): any;
|
|
49
|
+
isNeg(): boolean;
|
|
50
|
+
neg(): BN;
|
|
51
|
+
ineg(): this;
|
|
52
|
+
iuor(num: any): this;
|
|
53
|
+
ior(num: any): this;
|
|
54
|
+
or(num: any): any;
|
|
55
|
+
uor(num: any): any;
|
|
56
|
+
iuand(num: any): this;
|
|
57
|
+
iand(num: any): this;
|
|
58
|
+
and(num: any): any;
|
|
59
|
+
uand(num: any): any;
|
|
60
|
+
iuxor(num: any): this;
|
|
61
|
+
ixor(num: any): this;
|
|
62
|
+
xor(num: any): any;
|
|
63
|
+
uxor(num: any): any;
|
|
64
|
+
inotn(width: any): this;
|
|
65
|
+
notn(width: any): BN;
|
|
66
|
+
setn(bit: any, val: any): this;
|
|
67
|
+
iadd(num: any): any;
|
|
68
|
+
add(num: any): any;
|
|
69
|
+
isub(num: any): any;
|
|
70
|
+
sub(num: any): any;
|
|
71
|
+
mulTo(num: any, out: any): any;
|
|
72
|
+
mul(num: any): any;
|
|
73
|
+
mulf(num: any): any;
|
|
74
|
+
imul(num: any): any;
|
|
75
|
+
imuln(num: any): this;
|
|
76
|
+
muln(num: any): BN;
|
|
77
|
+
sqr(): any;
|
|
78
|
+
isqr(): any;
|
|
79
|
+
pow(num: any): BN;
|
|
80
|
+
iushln(bits: any): this;
|
|
81
|
+
ishln(bits: any): this;
|
|
82
|
+
iushrn(bits: any, hint: any, extended: any): this;
|
|
83
|
+
ishrn(bits: any, hint: any, extended: any): this;
|
|
84
|
+
shln(bits: any): BN;
|
|
85
|
+
ushln(bits: any): BN;
|
|
86
|
+
shrn(bits: any): BN;
|
|
87
|
+
ushrn(bits: any): BN;
|
|
88
|
+
testn(bit: any): boolean;
|
|
89
|
+
imaskn(bits: any): this;
|
|
90
|
+
maskn(bits: any): BN;
|
|
91
|
+
iaddn(num: any): any;
|
|
92
|
+
_iaddn(num: any): this;
|
|
93
|
+
isubn(num: any): any;
|
|
94
|
+
addn(num: any): any;
|
|
95
|
+
subn(num: any): any;
|
|
96
|
+
iabs(): this;
|
|
97
|
+
abs(): BN;
|
|
98
|
+
_ishlnsubmul(num: any, mul: any, shift: any): this;
|
|
99
|
+
_wordDiv(num: any, mode: any): {
|
|
100
|
+
div: BN;
|
|
101
|
+
mod: BN;
|
|
102
|
+
};
|
|
103
|
+
divmod(num: any, mode: any, positive: any): any;
|
|
104
|
+
div(num: any): any;
|
|
105
|
+
mod(num: any): any;
|
|
106
|
+
umod(num: any): any;
|
|
107
|
+
divRound(num: any): any;
|
|
108
|
+
modn(num: any): number;
|
|
109
|
+
idivn(num: any): this;
|
|
110
|
+
divn(num: any): BN;
|
|
111
|
+
egcd(p: any): {
|
|
112
|
+
a: BN;
|
|
113
|
+
b: BN;
|
|
114
|
+
gcd: any;
|
|
115
|
+
};
|
|
116
|
+
_invmp(p: any): BN;
|
|
117
|
+
gcd(num: any): any;
|
|
118
|
+
invm(num: any): any;
|
|
119
|
+
isEven(): boolean;
|
|
120
|
+
isOdd(): boolean;
|
|
121
|
+
andln(num: any): number;
|
|
122
|
+
bincn(bit: any): this;
|
|
123
|
+
isZero(): boolean;
|
|
124
|
+
cmpn(num: any): number;
|
|
125
|
+
cmp(num: any): number;
|
|
126
|
+
ucmp(num: any): number;
|
|
127
|
+
gtn(num: any): boolean;
|
|
128
|
+
gt(num: any): boolean;
|
|
129
|
+
gten(num: any): boolean;
|
|
130
|
+
gte(num: any): boolean;
|
|
131
|
+
ltn(num: any): boolean;
|
|
132
|
+
lt(num: any): boolean;
|
|
133
|
+
lten(num: any): boolean;
|
|
134
|
+
lte(num: any): boolean;
|
|
135
|
+
eqn(num: any): boolean;
|
|
136
|
+
eq(num: any): boolean;
|
|
137
|
+
toRed(ctx: any): any;
|
|
138
|
+
fromRed(): any;
|
|
139
|
+
_forceRed(ctx: any): this;
|
|
140
|
+
forceRed(ctx: any): this;
|
|
141
|
+
redAdd(num: any): any;
|
|
142
|
+
redIAdd(num: any): any;
|
|
143
|
+
redSub(num: any): any;
|
|
144
|
+
redISub(num: any): any;
|
|
145
|
+
redShl(num: any): any;
|
|
146
|
+
redMul(num: any): any;
|
|
147
|
+
redIMul(num: any): any;
|
|
148
|
+
redSqr(): any;
|
|
149
|
+
redISqr(): any;
|
|
150
|
+
redSqrt(): any;
|
|
151
|
+
redInvm(): any;
|
|
152
|
+
redNeg(): any;
|
|
153
|
+
redPow(num: any): any;
|
|
154
|
+
}
|
|
155
|
+
declare namespace BN {
|
|
156
|
+
export { BN };
|
|
157
|
+
export let wordSize: number;
|
|
158
|
+
export function isBN(num: any): boolean;
|
|
159
|
+
export function max(left: any, right: any): any;
|
|
160
|
+
export function min(left: any, right: any): any;
|
|
161
|
+
export function red(num: any): Red;
|
|
162
|
+
export function _prime(name: any): any;
|
|
163
|
+
export function mont(num: any): Mont;
|
|
164
|
+
}
|
|
165
|
+
declare function Red(m: any): void;
|
|
166
|
+
declare class Red {
|
|
167
|
+
constructor(m: any);
|
|
168
|
+
m: any;
|
|
169
|
+
prime: any;
|
|
170
|
+
_verify1(a: any): void;
|
|
171
|
+
_verify2(a: any, b: any): void;
|
|
172
|
+
imod(a: any): any;
|
|
173
|
+
neg(a: any): any;
|
|
174
|
+
add(a: any, b: any): any;
|
|
175
|
+
iadd(a: any, b: any): any;
|
|
176
|
+
sub(a: any, b: any): any;
|
|
177
|
+
isub(a: any, b: any): any;
|
|
178
|
+
shl(a: any, num: any): any;
|
|
179
|
+
imul(a: any, b: any): any;
|
|
180
|
+
mul(a: any, b: any): any;
|
|
181
|
+
isqr(a: any): any;
|
|
182
|
+
sqr(a: any): any;
|
|
183
|
+
sqrt(a: any): any;
|
|
184
|
+
invm(a: any): any;
|
|
185
|
+
pow(a: any, num: any): any;
|
|
186
|
+
convertTo(num: any): any;
|
|
187
|
+
convertFrom(num: any): any;
|
|
188
|
+
}
|
|
189
|
+
declare function Mont(m: any): void;
|
|
190
|
+
declare class Mont {
|
|
191
|
+
constructor(m: any);
|
|
192
|
+
shift: any;
|
|
193
|
+
r: BN;
|
|
194
|
+
r2: any;
|
|
195
|
+
rinv: BN;
|
|
196
|
+
minv: any;
|
|
197
|
+
convertTo(num: any): any;
|
|
198
|
+
convertFrom(num: any): any;
|
|
199
|
+
imul(a: any, b: any): any;
|
|
200
|
+
mul(a: any, b: any): any;
|
|
201
|
+
invm(a: any): any;
|
|
202
|
+
}
|