xpi-ts 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/LICENSE +21 -0
- package/README.md +516 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/lib/bitcore/address.d.ts +66 -0
- package/dist/lib/bitcore/address.d.ts.map +1 -0
- package/dist/lib/bitcore/address.js +407 -0
- package/dist/lib/bitcore/block/block.d.ts +57 -0
- package/dist/lib/bitcore/block/block.d.ts.map +1 -0
- package/dist/lib/bitcore/block/block.js +233 -0
- package/dist/lib/bitcore/block/blockheader.d.ts +82 -0
- package/dist/lib/bitcore/block/blockheader.d.ts.map +1 -0
- package/dist/lib/bitcore/block/blockheader.js +323 -0
- package/dist/lib/bitcore/block/index.d.ts +5 -0
- package/dist/lib/bitcore/block/index.d.ts.map +1 -0
- package/dist/lib/bitcore/block/index.js +2 -0
- package/dist/lib/bitcore/chunk.d.ts +22 -0
- package/dist/lib/bitcore/chunk.d.ts.map +1 -0
- package/dist/lib/bitcore/chunk.js +46 -0
- package/dist/lib/bitcore/crypto/bn.d.ts +53 -0
- package/dist/lib/bitcore/crypto/bn.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/bn.js +238 -0
- package/dist/lib/bitcore/crypto/ecdsa.d.ts +46 -0
- package/dist/lib/bitcore/crypto/ecdsa.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/ecdsa.js +247 -0
- package/dist/lib/bitcore/crypto/hash.d.ts +16 -0
- package/dist/lib/bitcore/crypto/hash.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/hash.js +87 -0
- package/dist/lib/bitcore/crypto/index.d.ts +9 -0
- package/dist/lib/bitcore/crypto/index.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/index.js +8 -0
- package/dist/lib/bitcore/crypto/musig2.d.ts +40 -0
- package/dist/lib/bitcore/crypto/musig2.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/musig2.js +236 -0
- package/dist/lib/bitcore/crypto/point.d.ts +20 -0
- package/dist/lib/bitcore/crypto/point.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/point.js +133 -0
- package/dist/lib/bitcore/crypto/random.d.ts +7 -0
- package/dist/lib/bitcore/crypto/random.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/random.js +30 -0
- package/dist/lib/bitcore/crypto/schnorr.d.ts +40 -0
- package/dist/lib/bitcore/crypto/schnorr.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/schnorr.js +185 -0
- package/dist/lib/bitcore/crypto/signature.d.ts +53 -0
- package/dist/lib/bitcore/crypto/signature.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/signature.js +300 -0
- package/dist/lib/bitcore/crypto/sigtype.d.ts +5 -0
- package/dist/lib/bitcore/crypto/sigtype.d.ts.map +1 -0
- package/dist/lib/bitcore/crypto/sigtype.js +18 -0
- package/dist/lib/bitcore/encoding/base58.d.ts +16 -0
- package/dist/lib/bitcore/encoding/base58.d.ts.map +1 -0
- package/dist/lib/bitcore/encoding/base58.js +55 -0
- package/dist/lib/bitcore/encoding/base58check.d.ts +9 -0
- package/dist/lib/bitcore/encoding/base58check.d.ts.map +1 -0
- package/dist/lib/bitcore/encoding/base58check.js +82 -0
- package/dist/lib/bitcore/encoding/bufferreader.d.ts +34 -0
- package/dist/lib/bitcore/encoding/bufferreader.d.ts.map +1 -0
- package/dist/lib/bitcore/encoding/bufferreader.js +198 -0
- package/dist/lib/bitcore/encoding/bufferwriter.d.ts +36 -0
- package/dist/lib/bitcore/encoding/bufferwriter.d.ts.map +1 -0
- package/dist/lib/bitcore/encoding/bufferwriter.js +189 -0
- package/dist/lib/bitcore/encoding/varint.d.ts +20 -0
- package/dist/lib/bitcore/encoding/varint.d.ts.map +1 -0
- package/dist/lib/bitcore/encoding/varint.js +61 -0
- package/dist/lib/bitcore/errors.d.ts +28 -0
- package/dist/lib/bitcore/errors.d.ts.map +1 -0
- package/dist/lib/bitcore/errors.js +325 -0
- package/dist/lib/bitcore/hdprivatekey.d.ts +78 -0
- package/dist/lib/bitcore/hdprivatekey.d.ts.map +1 -0
- package/dist/lib/bitcore/hdprivatekey.js +381 -0
- package/dist/lib/bitcore/hdpublickey.d.ts +98 -0
- package/dist/lib/bitcore/hdpublickey.d.ts.map +1 -0
- package/dist/lib/bitcore/hdpublickey.js +416 -0
- package/dist/lib/bitcore/index.d.ts +60 -0
- package/dist/lib/bitcore/index.d.ts.map +1 -0
- package/dist/lib/bitcore/index.js +44 -0
- package/dist/lib/bitcore/message.d.ts +23 -0
- package/dist/lib/bitcore/message.d.ts.map +1 -0
- package/dist/lib/bitcore/message.js +112 -0
- package/dist/lib/bitcore/mnemonic/errors.d.ts +7 -0
- package/dist/lib/bitcore/mnemonic/errors.d.ts.map +1 -0
- package/dist/lib/bitcore/mnemonic/errors.js +20 -0
- package/dist/lib/bitcore/mnemonic/index.d.ts +5 -0
- package/dist/lib/bitcore/mnemonic/index.d.ts.map +1 -0
- package/dist/lib/bitcore/mnemonic/index.js +4 -0
- package/dist/lib/bitcore/mnemonic/mnemonic.d.ts +23 -0
- package/dist/lib/bitcore/mnemonic/mnemonic.d.ts.map +1 -0
- package/dist/lib/bitcore/mnemonic/mnemonic.js +164 -0
- package/dist/lib/bitcore/mnemonic/pbkdf2.d.ts +2 -0
- package/dist/lib/bitcore/mnemonic/pbkdf2.d.ts.map +1 -0
- package/dist/lib/bitcore/mnemonic/pbkdf2.js +25 -0
- package/dist/lib/bitcore/mnemonic/words/english.d.ts +2 -0
- package/dist/lib/bitcore/mnemonic/words/english.d.ts.map +1 -0
- package/dist/lib/bitcore/mnemonic/words/english.js +2050 -0
- package/dist/lib/bitcore/mnemonic/words/index.d.ts +4 -0
- package/dist/lib/bitcore/mnemonic/words/index.d.ts.map +1 -0
- package/dist/lib/bitcore/mnemonic/words/index.js +4 -0
- package/dist/lib/bitcore/musig2/index.d.ts +3 -0
- package/dist/lib/bitcore/musig2/index.d.ts.map +1 -0
- package/dist/lib/bitcore/musig2/index.js +2 -0
- package/dist/lib/bitcore/musig2/session.d.ts +79 -0
- package/dist/lib/bitcore/musig2/session.d.ts.map +1 -0
- package/dist/lib/bitcore/musig2/session.js +346 -0
- package/dist/lib/bitcore/musig2/signer.d.ts +61 -0
- package/dist/lib/bitcore/musig2/signer.d.ts.map +1 -0
- package/dist/lib/bitcore/musig2/signer.js +146 -0
- package/dist/lib/bitcore/networks.d.ts +53 -0
- package/dist/lib/bitcore/networks.d.ts.map +1 -0
- package/dist/lib/bitcore/networks.js +150 -0
- package/dist/lib/bitcore/opcode.d.ts +250 -0
- package/dist/lib/bitcore/opcode.d.ts.map +1 -0
- package/dist/lib/bitcore/opcode.js +270 -0
- package/dist/lib/bitcore/privatekey.d.ts +56 -0
- package/dist/lib/bitcore/privatekey.d.ts.map +1 -0
- package/dist/lib/bitcore/privatekey.js +237 -0
- package/dist/lib/bitcore/publickey.d.ts +59 -0
- package/dist/lib/bitcore/publickey.d.ts.map +1 -0
- package/dist/lib/bitcore/publickey.js +263 -0
- package/dist/lib/bitcore/script/interpreter.d.ts +98 -0
- package/dist/lib/bitcore/script/interpreter.d.ts.map +1 -0
- package/dist/lib/bitcore/script/interpreter.js +1704 -0
- package/dist/lib/bitcore/script.d.ts +111 -0
- package/dist/lib/bitcore/script.d.ts.map +1 -0
- package/dist/lib/bitcore/script.js +1112 -0
- package/dist/lib/bitcore/taproot/musig2.d.ts +29 -0
- package/dist/lib/bitcore/taproot/musig2.d.ts.map +1 -0
- package/dist/lib/bitcore/taproot/musig2.js +104 -0
- package/dist/lib/bitcore/taproot/nft.d.ts +164 -0
- package/dist/lib/bitcore/taproot/nft.d.ts.map +1 -0
- package/dist/lib/bitcore/taproot/nft.js +407 -0
- package/dist/lib/bitcore/taproot.d.ts +65 -0
- package/dist/lib/bitcore/taproot.d.ts.map +1 -0
- package/dist/lib/bitcore/taproot.js +288 -0
- package/dist/lib/bitcore/transaction/index.d.ts +12 -0
- package/dist/lib/bitcore/transaction/index.d.ts.map +1 -0
- package/dist/lib/bitcore/transaction/index.js +6 -0
- package/dist/lib/bitcore/transaction/input.d.ts +202 -0
- package/dist/lib/bitcore/transaction/input.d.ts.map +1 -0
- package/dist/lib/bitcore/transaction/input.js +911 -0
- package/dist/lib/bitcore/transaction/output.d.ts +48 -0
- package/dist/lib/bitcore/transaction/output.d.ts.map +1 -0
- package/dist/lib/bitcore/transaction/output.js +231 -0
- package/dist/lib/bitcore/transaction/sighash.d.ts +32 -0
- package/dist/lib/bitcore/transaction/sighash.d.ts.map +1 -0
- package/dist/lib/bitcore/transaction/sighash.js +335 -0
- package/dist/lib/bitcore/transaction/signature.d.ts +36 -0
- package/dist/lib/bitcore/transaction/signature.d.ts.map +1 -0
- package/dist/lib/bitcore/transaction/signature.js +130 -0
- package/dist/lib/bitcore/transaction/transaction.d.ts +164 -0
- package/dist/lib/bitcore/transaction/transaction.d.ts.map +1 -0
- package/dist/lib/bitcore/transaction/transaction.js +1016 -0
- package/dist/lib/bitcore/transaction/unspentoutput.d.ts +58 -0
- package/dist/lib/bitcore/transaction/unspentoutput.d.ts.map +1 -0
- package/dist/lib/bitcore/transaction/unspentoutput.js +167 -0
- package/dist/lib/bitcore/unit.d.ts +44 -0
- package/dist/lib/bitcore/unit.d.ts.map +1 -0
- package/dist/lib/bitcore/unit.js +106 -0
- package/dist/lib/bitcore/uri.d.ts +29 -0
- package/dist/lib/bitcore/uri.d.ts.map +1 -0
- package/dist/lib/bitcore/uri.js +163 -0
- package/dist/lib/bitcore/util/base32.d.ts +5 -0
- package/dist/lib/bitcore/util/base32.d.ts.map +1 -0
- package/dist/lib/bitcore/util/base32.js +58 -0
- package/dist/lib/bitcore/util/buffer.d.ts +18 -0
- package/dist/lib/bitcore/util/buffer.d.ts.map +1 -0
- package/dist/lib/bitcore/util/buffer.js +76 -0
- package/dist/lib/bitcore/util/convertBits.d.ts +2 -0
- package/dist/lib/bitcore/util/convertBits.d.ts.map +1 -0
- package/dist/lib/bitcore/util/convertBits.js +26 -0
- package/dist/lib/bitcore/util/js.d.ts +9 -0
- package/dist/lib/bitcore/util/js.d.ts.map +1 -0
- package/dist/lib/bitcore/util/js.js +45 -0
- package/dist/lib/bitcore/util/preconditions.d.ts +6 -0
- package/dist/lib/bitcore/util/preconditions.d.ts.map +1 -0
- package/dist/lib/bitcore/util/preconditions.js +31 -0
- package/dist/lib/bitcore/util.d.ts +14 -0
- package/dist/lib/bitcore/util.d.ts.map +1 -0
- package/dist/lib/bitcore/util.js +13 -0
- package/dist/lib/bitcore/xaddress.d.ts +45 -0
- package/dist/lib/bitcore/xaddress.d.ts.map +1 -0
- package/dist/lib/bitcore/xaddress.js +279 -0
- package/dist/lib/rank/api.d.ts +75 -0
- package/dist/lib/rank/api.d.ts.map +1 -0
- package/dist/lib/rank/api.js +4 -0
- package/dist/lib/rank/index.d.ts +127 -0
- package/dist/lib/rank/index.d.ts.map +1 -0
- package/dist/lib/rank/index.js +421 -0
- package/dist/lib/rank/opcode.d.ts +23 -0
- package/dist/lib/rank/opcode.d.ts.map +1 -0
- package/dist/lib/rank/opcode.js +23 -0
- package/dist/lib/rank/script.d.ts +2 -0
- package/dist/lib/rank/script.d.ts.map +1 -0
- package/dist/lib/rank/script.js +7 -0
- package/dist/lib/rank/transaction.d.ts +3 -0
- package/dist/lib/rank/transaction.d.ts.map +1 -0
- package/dist/lib/rank/transaction.js +12 -0
- package/dist/lib/rpc.d.ts +136 -0
- package/dist/lib/rpc.d.ts.map +1 -0
- package/dist/lib/rpc.js +62 -0
- package/dist/utils/constants.d.ts +18 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +20 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +8 -0
- package/dist/utils/string.d.ts +11 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +47 -0
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +1 -0
- package/dist/utils/wallet.d.ts +12 -0
- package/dist/utils/wallet.d.ts.map +1 -0
- package/dist/utils/wallet.js +28 -0
- package/package.json +91 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BufferReader } from '../encoding/bufferreader.js';
|
|
2
|
+
import { BufferWriter } from '../encoding/bufferwriter.js';
|
|
3
|
+
import { BN } from '../crypto/bn.js';
|
|
4
|
+
export interface BlockHeaderData {
|
|
5
|
+
prevHash?: Buffer | string;
|
|
6
|
+
bits?: number;
|
|
7
|
+
time?: number;
|
|
8
|
+
timestamp?: number;
|
|
9
|
+
reserved?: number;
|
|
10
|
+
nonce?: BN;
|
|
11
|
+
version?: number;
|
|
12
|
+
size?: BN;
|
|
13
|
+
height?: number;
|
|
14
|
+
epochBlock?: Buffer | string;
|
|
15
|
+
merkleRoot?: Buffer | string;
|
|
16
|
+
extendedMetadata?: Buffer | string;
|
|
17
|
+
hash?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface BlockHeaderObject {
|
|
20
|
+
hash: string;
|
|
21
|
+
prevHash: string;
|
|
22
|
+
bits: number;
|
|
23
|
+
time: number;
|
|
24
|
+
reserved: number;
|
|
25
|
+
nonce: string;
|
|
26
|
+
version: number;
|
|
27
|
+
size: number;
|
|
28
|
+
height: number;
|
|
29
|
+
epochBlock: string;
|
|
30
|
+
merkleRoot: string;
|
|
31
|
+
extendedMetadata: string;
|
|
32
|
+
}
|
|
33
|
+
export declare class BlockHeader {
|
|
34
|
+
static readonly Constants: {
|
|
35
|
+
START_OF_HEADER: number;
|
|
36
|
+
MAX_TIME_OFFSET: number;
|
|
37
|
+
LARGEST_HASH: BN;
|
|
38
|
+
};
|
|
39
|
+
static readonly START_OF_HEADER = 0;
|
|
40
|
+
static readonly MAX_TIME_OFFSET: number;
|
|
41
|
+
static readonly LARGEST_HASH: bigint;
|
|
42
|
+
prevHash: Buffer;
|
|
43
|
+
bits: number;
|
|
44
|
+
time: number;
|
|
45
|
+
timestamp: number;
|
|
46
|
+
reserved: number;
|
|
47
|
+
nonce: BN;
|
|
48
|
+
version: number;
|
|
49
|
+
size: BN;
|
|
50
|
+
height: number;
|
|
51
|
+
epochBlock: Buffer;
|
|
52
|
+
merkleRoot: Buffer;
|
|
53
|
+
extendedMetadata: Buffer;
|
|
54
|
+
private _id?;
|
|
55
|
+
constructor(arg?: BlockHeaderData | BlockHeader);
|
|
56
|
+
private static _from;
|
|
57
|
+
private static _fromObject;
|
|
58
|
+
static fromObject(obj: BlockHeaderData): BlockHeader;
|
|
59
|
+
static fromRawBlock(data: Buffer | string): BlockHeader;
|
|
60
|
+
static fromBuffer(buf: Buffer): BlockHeader;
|
|
61
|
+
static fromString(str: string): BlockHeader;
|
|
62
|
+
private static _fromBufferReader;
|
|
63
|
+
static fromBufferReader(br: BufferReader): BlockHeader;
|
|
64
|
+
toObject(): BlockHeaderObject;
|
|
65
|
+
toJSON: () => BlockHeaderObject;
|
|
66
|
+
toBuffer(): Buffer;
|
|
67
|
+
toString(): string;
|
|
68
|
+
toBufferWriter(bw?: BufferWriter): BufferWriter;
|
|
69
|
+
getTargetDifficulty(bits?: number): BN;
|
|
70
|
+
getDifficulty(): number;
|
|
71
|
+
private _getHash;
|
|
72
|
+
private _timeToBytes;
|
|
73
|
+
private _sizeToBytes;
|
|
74
|
+
private _getLayer3Hash;
|
|
75
|
+
private _getLayer2Hash;
|
|
76
|
+
get hash(): string;
|
|
77
|
+
get id(): string;
|
|
78
|
+
validTimestamp(): boolean;
|
|
79
|
+
validProofOfWork(): boolean;
|
|
80
|
+
inspect(): string;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=blockheader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockheader.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/block/blockheader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AA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,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,cAAc;IAetB,IAAI,IAAI,IAAI,MAAM,CAOjB;IAKD,IAAI,EAAE,IAAI,MAAM,CAEf;IAKD,cAAc,IAAI,OAAO;IAWzB,gBAAgB,IAAI,OAAO;IAc3B,OAAO,IAAI,MAAM;CAGlB"}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { Preconditions } from '../util/preconditions.js';
|
|
2
|
+
import { BufferUtil } from '../util/buffer.js';
|
|
3
|
+
import { BufferReader } from '../encoding/bufferreader.js';
|
|
4
|
+
import { BufferWriter } from '../encoding/bufferwriter.js';
|
|
5
|
+
import { Hash } from '../crypto/hash.js';
|
|
6
|
+
import { JSUtil } from '../util/js.js';
|
|
7
|
+
import { BN } from '../crypto/bn.js';
|
|
8
|
+
const GENESIS_BITS = 0x1d00ffff;
|
|
9
|
+
export class BlockHeader {
|
|
10
|
+
static Constants = {
|
|
11
|
+
START_OF_HEADER: 0,
|
|
12
|
+
MAX_TIME_OFFSET: 2 * 60 * 60,
|
|
13
|
+
LARGEST_HASH: new BN('10000000000000000000000000000000000000000000000000000000000000000', 'hex'),
|
|
14
|
+
};
|
|
15
|
+
static START_OF_HEADER = 0;
|
|
16
|
+
static MAX_TIME_OFFSET = 2 * 60 * 60;
|
|
17
|
+
static LARGEST_HASH = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000');
|
|
18
|
+
prevHash;
|
|
19
|
+
bits;
|
|
20
|
+
time;
|
|
21
|
+
timestamp;
|
|
22
|
+
reserved;
|
|
23
|
+
nonce;
|
|
24
|
+
version;
|
|
25
|
+
size;
|
|
26
|
+
height;
|
|
27
|
+
epochBlock;
|
|
28
|
+
merkleRoot;
|
|
29
|
+
extendedMetadata;
|
|
30
|
+
_id;
|
|
31
|
+
constructor(arg) {
|
|
32
|
+
if (arg instanceof BlockHeader) {
|
|
33
|
+
return arg;
|
|
34
|
+
}
|
|
35
|
+
this.prevHash = Buffer.alloc(32);
|
|
36
|
+
this.bits = 0;
|
|
37
|
+
this.time = 0;
|
|
38
|
+
this.timestamp = 0;
|
|
39
|
+
this.reserved = 0;
|
|
40
|
+
this.nonce = new BN(0);
|
|
41
|
+
this.version = 0;
|
|
42
|
+
this.size = new BN(0);
|
|
43
|
+
this.height = 0;
|
|
44
|
+
this.epochBlock = Buffer.alloc(32);
|
|
45
|
+
this.merkleRoot = Buffer.alloc(32);
|
|
46
|
+
this.extendedMetadata = Buffer.alloc(32);
|
|
47
|
+
if (arg && typeof arg === 'object') {
|
|
48
|
+
const info = BlockHeader._from(arg);
|
|
49
|
+
this.prevHash = info.prevHash;
|
|
50
|
+
this.bits = info.bits;
|
|
51
|
+
this.time = info.time;
|
|
52
|
+
this.timestamp = info.time;
|
|
53
|
+
this.reserved = info.reserved || 0;
|
|
54
|
+
this.nonce = info.nonce;
|
|
55
|
+
this.version = info.version;
|
|
56
|
+
this.size = info.size;
|
|
57
|
+
this.height = info.height;
|
|
58
|
+
this.epochBlock = info.epochBlock;
|
|
59
|
+
this.merkleRoot = info.merkleRoot;
|
|
60
|
+
this.extendedMetadata = info.extendedMetadata;
|
|
61
|
+
if (info.hash) {
|
|
62
|
+
Preconditions.checkState(this.hash === info.hash, 'Argument object hash property does not match block hash.');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static _from(arg) {
|
|
67
|
+
let info = {};
|
|
68
|
+
if (Buffer.isBuffer(arg)) {
|
|
69
|
+
info = BlockHeader._fromBufferReader(new BufferReader(arg));
|
|
70
|
+
}
|
|
71
|
+
else if (typeof arg === 'string' && JSUtil.isHexa(arg)) {
|
|
72
|
+
const buf = Buffer.from(arg, 'hex');
|
|
73
|
+
info = BlockHeader._fromBufferReader(new BufferReader(buf));
|
|
74
|
+
}
|
|
75
|
+
else if (typeof arg === 'object' && arg !== null) {
|
|
76
|
+
info = BlockHeader._fromObject(arg);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
throw new TypeError('Unrecognized argument for BlockHeader');
|
|
80
|
+
}
|
|
81
|
+
return info;
|
|
82
|
+
}
|
|
83
|
+
static _fromObject(data) {
|
|
84
|
+
Preconditions.checkArgument(typeof data === 'object' && data !== null, 'data is required');
|
|
85
|
+
let prevHash = data.prevHash;
|
|
86
|
+
let merkleRoot = data.merkleRoot;
|
|
87
|
+
let epochBlock = data.epochBlock;
|
|
88
|
+
let extendedMetadata = data.extendedMetadata;
|
|
89
|
+
let nonce = data.nonce;
|
|
90
|
+
let size = data.size;
|
|
91
|
+
if (typeof data.prevHash === 'string') {
|
|
92
|
+
prevHash = BufferUtil.reverse(Buffer.from(data.prevHash, 'hex'));
|
|
93
|
+
}
|
|
94
|
+
else if (!Buffer.isBuffer(data.prevHash)) {
|
|
95
|
+
prevHash = Buffer.alloc(32);
|
|
96
|
+
}
|
|
97
|
+
if (typeof data.merkleRoot === 'string') {
|
|
98
|
+
merkleRoot = BufferUtil.reverse(Buffer.from(data.merkleRoot, 'hex'));
|
|
99
|
+
}
|
|
100
|
+
else if (!Buffer.isBuffer(data.merkleRoot)) {
|
|
101
|
+
merkleRoot = Buffer.alloc(32);
|
|
102
|
+
}
|
|
103
|
+
if (typeof data.epochBlock === 'string') {
|
|
104
|
+
epochBlock = BufferUtil.reverse(Buffer.from(data.epochBlock, 'hex'));
|
|
105
|
+
}
|
|
106
|
+
else if (!Buffer.isBuffer(data.epochBlock)) {
|
|
107
|
+
epochBlock = Buffer.alloc(32);
|
|
108
|
+
}
|
|
109
|
+
if (typeof data.extendedMetadata === 'string') {
|
|
110
|
+
extendedMetadata = BufferUtil.reverse(Buffer.from(data.extendedMetadata, 'hex'));
|
|
111
|
+
}
|
|
112
|
+
else if (!Buffer.isBuffer(data.extendedMetadata)) {
|
|
113
|
+
extendedMetadata = Buffer.alloc(32);
|
|
114
|
+
}
|
|
115
|
+
if (typeof data.nonce === 'string') {
|
|
116
|
+
nonce = new BN(data.nonce, 10);
|
|
117
|
+
}
|
|
118
|
+
else if (typeof data.nonce === 'number') {
|
|
119
|
+
nonce = new BN(data.nonce);
|
|
120
|
+
}
|
|
121
|
+
else if (data.nonce instanceof BN) {
|
|
122
|
+
nonce = data.nonce;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
nonce = new BN(0);
|
|
126
|
+
}
|
|
127
|
+
if (typeof data.size === 'string') {
|
|
128
|
+
size = new BN(data.size, 10);
|
|
129
|
+
}
|
|
130
|
+
else if (typeof data.size === 'number') {
|
|
131
|
+
size = new BN(data.size);
|
|
132
|
+
}
|
|
133
|
+
else if (data.size instanceof BN) {
|
|
134
|
+
size = data.size;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
size = new BN(0);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
hash: data.hash,
|
|
141
|
+
prevHash: prevHash,
|
|
142
|
+
bits: data.bits || 0,
|
|
143
|
+
timestamp: data.time || data.timestamp || 0,
|
|
144
|
+
reserved: data.reserved || 0,
|
|
145
|
+
nonce: nonce,
|
|
146
|
+
version: data.version || 0,
|
|
147
|
+
size: size,
|
|
148
|
+
height: data.height || 0,
|
|
149
|
+
epochBlock: epochBlock,
|
|
150
|
+
merkleRoot: merkleRoot,
|
|
151
|
+
extendedMetadata: extendedMetadata,
|
|
152
|
+
time: data.time || data.timestamp || 0,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
static fromObject(obj) {
|
|
156
|
+
const info = BlockHeader._fromObject(obj);
|
|
157
|
+
return new BlockHeader(info);
|
|
158
|
+
}
|
|
159
|
+
static fromRawBlock(data) {
|
|
160
|
+
if (!Buffer.isBuffer(data)) {
|
|
161
|
+
data = Buffer.from(data, 'binary');
|
|
162
|
+
}
|
|
163
|
+
const br = new BufferReader(data);
|
|
164
|
+
br.pos = BlockHeader.Constants.START_OF_HEADER;
|
|
165
|
+
const info = BlockHeader._fromBufferReader(br);
|
|
166
|
+
return new BlockHeader(info);
|
|
167
|
+
}
|
|
168
|
+
static fromBuffer(buf) {
|
|
169
|
+
const info = BlockHeader._fromBufferReader(new BufferReader(buf));
|
|
170
|
+
return new BlockHeader(info);
|
|
171
|
+
}
|
|
172
|
+
static fromString(str) {
|
|
173
|
+
const buf = Buffer.from(str, 'hex');
|
|
174
|
+
return BlockHeader.fromBuffer(buf);
|
|
175
|
+
}
|
|
176
|
+
static _fromBufferReader(br) {
|
|
177
|
+
return {
|
|
178
|
+
prevHash: br.read(32),
|
|
179
|
+
bits: br.readUInt32LE(),
|
|
180
|
+
time: br.readUInt48LE(),
|
|
181
|
+
reserved: br.readUInt16LE(),
|
|
182
|
+
nonce: br.readUInt64LEBN(),
|
|
183
|
+
version: br.readUInt8(),
|
|
184
|
+
size: br.readUInt56LEBN(),
|
|
185
|
+
height: br.readUInt32LE(),
|
|
186
|
+
epochBlock: br.read(32),
|
|
187
|
+
merkleRoot: br.read(32),
|
|
188
|
+
extendedMetadata: br.read(32),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
static fromBufferReader(br) {
|
|
192
|
+
const info = BlockHeader._fromBufferReader(br);
|
|
193
|
+
return new BlockHeader(info);
|
|
194
|
+
}
|
|
195
|
+
toObject() {
|
|
196
|
+
return {
|
|
197
|
+
hash: this.hash,
|
|
198
|
+
prevHash: BufferUtil.reverse(this.prevHash).toString('hex'),
|
|
199
|
+
bits: this.bits,
|
|
200
|
+
time: this.time,
|
|
201
|
+
reserved: this.reserved,
|
|
202
|
+
nonce: this.nonce.toString(10),
|
|
203
|
+
version: this.version,
|
|
204
|
+
size: this.size.toNumber(),
|
|
205
|
+
height: this.height,
|
|
206
|
+
epochBlock: BufferUtil.reverse(this.epochBlock).toString('hex'),
|
|
207
|
+
merkleRoot: BufferUtil.reverse(this.merkleRoot).toString('hex'),
|
|
208
|
+
extendedMetadata: BufferUtil.reverse(this.extendedMetadata).toString('hex'),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
toJSON = this.toObject;
|
|
212
|
+
toBuffer() {
|
|
213
|
+
return this.toBufferWriter().toBuffer();
|
|
214
|
+
}
|
|
215
|
+
toString() {
|
|
216
|
+
return this.toBuffer().toString('hex');
|
|
217
|
+
}
|
|
218
|
+
toBufferWriter(bw) {
|
|
219
|
+
if (!bw) {
|
|
220
|
+
bw = new BufferWriter();
|
|
221
|
+
}
|
|
222
|
+
bw.write(this.prevHash);
|
|
223
|
+
bw.writeUInt32LE(this.bits);
|
|
224
|
+
bw.writeUInt48LE(this.time);
|
|
225
|
+
bw.writeUInt16LE(this.reserved);
|
|
226
|
+
bw.writeUInt64LEBN(this.nonce);
|
|
227
|
+
bw.writeUInt8(this.version);
|
|
228
|
+
bw.writeUInt56LEBN(this.size);
|
|
229
|
+
bw.writeUInt32LE(this.height);
|
|
230
|
+
bw.write(this.epochBlock);
|
|
231
|
+
bw.write(this.merkleRoot);
|
|
232
|
+
bw.write(this.extendedMetadata);
|
|
233
|
+
return bw;
|
|
234
|
+
}
|
|
235
|
+
getTargetDifficulty(bits) {
|
|
236
|
+
bits = bits || this.bits;
|
|
237
|
+
let target = new BN(bits & 0xffffff);
|
|
238
|
+
let mov = 8 * ((bits >>> 24) - 3);
|
|
239
|
+
while (mov-- > 0) {
|
|
240
|
+
target = target.mul(new BN(2));
|
|
241
|
+
}
|
|
242
|
+
return target;
|
|
243
|
+
}
|
|
244
|
+
getDifficulty() {
|
|
245
|
+
const difficulty1TargetBN = this.getTargetDifficulty(GENESIS_BITS).mul(new BN(Math.pow(10, 8)));
|
|
246
|
+
const currentTargetBN = this.getTargetDifficulty();
|
|
247
|
+
const difficultyString = difficulty1TargetBN
|
|
248
|
+
.div(currentTargetBN)
|
|
249
|
+
.toString(10);
|
|
250
|
+
const decimalPos = difficultyString.length - 8;
|
|
251
|
+
const formattedDifficulty = difficultyString.slice(0, decimalPos) +
|
|
252
|
+
'.' +
|
|
253
|
+
difficultyString.slice(decimalPos);
|
|
254
|
+
return parseFloat(formattedDifficulty);
|
|
255
|
+
}
|
|
256
|
+
_getHash() {
|
|
257
|
+
const layer3Hash = this._getLayer3Hash();
|
|
258
|
+
const layer2Hash = this._getLayer2Hash(layer3Hash);
|
|
259
|
+
const bw = new BufferWriter();
|
|
260
|
+
bw.write(this.prevHash);
|
|
261
|
+
bw.write(layer2Hash);
|
|
262
|
+
return Hash.sha256(bw.toBuffer());
|
|
263
|
+
}
|
|
264
|
+
_timeToBytes() {
|
|
265
|
+
const buf = Buffer.alloc(6);
|
|
266
|
+
buf.writeUIntLE(this.time, 0, 6);
|
|
267
|
+
return buf;
|
|
268
|
+
}
|
|
269
|
+
_sizeToBytes() {
|
|
270
|
+
const buf = Buffer.alloc(7);
|
|
271
|
+
const sizeBuffer = this.size.toArrayLike(Buffer, 'le', 7);
|
|
272
|
+
sizeBuffer.copy(buf);
|
|
273
|
+
return buf;
|
|
274
|
+
}
|
|
275
|
+
_getLayer3Hash() {
|
|
276
|
+
const bw = new BufferWriter();
|
|
277
|
+
bw.writeUInt8(this.version);
|
|
278
|
+
bw.writeUInt56LEBN(this.size);
|
|
279
|
+
bw.writeUInt32LE(this.height);
|
|
280
|
+
bw.write(this.epochBlock);
|
|
281
|
+
bw.write(this.merkleRoot);
|
|
282
|
+
bw.write(this.extendedMetadata);
|
|
283
|
+
return Hash.sha256(bw.toBuffer());
|
|
284
|
+
}
|
|
285
|
+
_getLayer2Hash(layer3Hash) {
|
|
286
|
+
const bw = new BufferWriter();
|
|
287
|
+
bw.writeUInt32LE(this.bits);
|
|
288
|
+
bw.writeUInt48LE(this.time);
|
|
289
|
+
bw.writeUInt16LE(this.reserved);
|
|
290
|
+
bw.writeUInt64LEBN(this.nonce);
|
|
291
|
+
bw.write(layer3Hash);
|
|
292
|
+
return Hash.sha256(bw.toBuffer());
|
|
293
|
+
}
|
|
294
|
+
get hash() {
|
|
295
|
+
if (!this._id) {
|
|
296
|
+
const hashBuffer = this._getHash();
|
|
297
|
+
const reader = new BufferReader(hashBuffer);
|
|
298
|
+
this._id = reader.readReverse(32).toString('hex');
|
|
299
|
+
}
|
|
300
|
+
return this._id;
|
|
301
|
+
}
|
|
302
|
+
get id() {
|
|
303
|
+
return this.hash;
|
|
304
|
+
}
|
|
305
|
+
validTimestamp() {
|
|
306
|
+
const currentTime = Math.round(new Date().getTime() / 1000);
|
|
307
|
+
if (this.time > currentTime + BlockHeader.Constants.MAX_TIME_OFFSET) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
validProofOfWork() {
|
|
313
|
+
const pow = new BN(this.id, 'hex');
|
|
314
|
+
const target = this.getTargetDifficulty();
|
|
315
|
+
if (pow.gt(target)) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
inspect() {
|
|
321
|
+
return '<BlockHeader ' + this.id + '>';
|
|
322
|
+
}
|
|
323
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/block/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxD,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class Chunk {
|
|
2
|
+
buf?: Buffer;
|
|
3
|
+
len?: number;
|
|
4
|
+
opcodenum: number;
|
|
5
|
+
constructor(data?: {
|
|
6
|
+
buf?: Buffer;
|
|
7
|
+
len?: number;
|
|
8
|
+
opcodenum: number;
|
|
9
|
+
});
|
|
10
|
+
isOpCode(): boolean;
|
|
11
|
+
hasData(): boolean;
|
|
12
|
+
getLength(): number;
|
|
13
|
+
getBuffer(): Buffer | undefined;
|
|
14
|
+
getOpCode(): number;
|
|
15
|
+
toString(): string;
|
|
16
|
+
toObject(): {
|
|
17
|
+
buf?: Buffer;
|
|
18
|
+
len?: number;
|
|
19
|
+
opcodenum: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=chunk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../lib/bitcore/chunk.ts"],"names":[],"mappings":"AAMA,qBAAa,KAAK;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;gBAEL,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAapE,QAAQ,IAAI,OAAO;IAOnB,OAAO,IAAI,OAAO;IAOlB,SAAS,IAAI,MAAM;IAOnB,SAAS,IAAI,MAAM,GAAG,SAAS;IAO/B,SAAS,IAAI,MAAM;IAOnB,QAAQ,IAAI,MAAM;IAYlB,QAAQ,IAAI;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;CAO9D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class Chunk {
|
|
2
|
+
buf;
|
|
3
|
+
len;
|
|
4
|
+
opcodenum;
|
|
5
|
+
constructor(data) {
|
|
6
|
+
if (data) {
|
|
7
|
+
this.buf = data.buf;
|
|
8
|
+
this.len = data.len;
|
|
9
|
+
this.opcodenum = data.opcodenum;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
this.opcodenum = 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
isOpCode() {
|
|
16
|
+
return !this.buf && this.opcodenum !== undefined;
|
|
17
|
+
}
|
|
18
|
+
hasData() {
|
|
19
|
+
return !!this.buf;
|
|
20
|
+
}
|
|
21
|
+
getLength() {
|
|
22
|
+
return this.len || 0;
|
|
23
|
+
}
|
|
24
|
+
getBuffer() {
|
|
25
|
+
return this.buf;
|
|
26
|
+
}
|
|
27
|
+
getOpCode() {
|
|
28
|
+
return this.opcodenum;
|
|
29
|
+
}
|
|
30
|
+
toString() {
|
|
31
|
+
if (this.isOpCode()) {
|
|
32
|
+
return `OP_${this.opcodenum}`;
|
|
33
|
+
}
|
|
34
|
+
else if (this.buf) {
|
|
35
|
+
return this.buf.toString('hex');
|
|
36
|
+
}
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
toObject() {
|
|
40
|
+
return {
|
|
41
|
+
buf: this.buf,
|
|
42
|
+
len: this.len,
|
|
43
|
+
opcodenum: this.opcodenum,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
export interface BNWrapperOptions {
|
|
3
|
+
endian?: 'little' | 'big';
|
|
4
|
+
size?: number;
|
|
5
|
+
}
|
|
6
|
+
declare class BNWrapper {
|
|
7
|
+
private _bn;
|
|
8
|
+
static readonly Zero: BNWrapper;
|
|
9
|
+
static readonly One: BNWrapper;
|
|
10
|
+
static readonly Minus1: BNWrapper;
|
|
11
|
+
constructor(n: number | string | BN | Buffer, base?: number | 'hex' | 'le' | 'be');
|
|
12
|
+
static fromString(str: string, base?: number): BNWrapper;
|
|
13
|
+
static fromBuffer(buf: Buffer, opts?: BNWrapperOptions): BNWrapper;
|
|
14
|
+
static fromSM(buf: Buffer, opts?: BNWrapperOptions): BNWrapper;
|
|
15
|
+
static fromScriptNumBuffer(buf: Buffer, fRequireMinimal?: boolean, size?: number): BNWrapper;
|
|
16
|
+
static reversebuf(buf: Buffer): Buffer;
|
|
17
|
+
static trim(buf: Buffer, natlen: number): Buffer;
|
|
18
|
+
static pad(buf: Buffer, natlen: number, size: number): Buffer;
|
|
19
|
+
static fromNumber(n: number): BNWrapper;
|
|
20
|
+
toNumber(): number;
|
|
21
|
+
add(r: BNWrapper): BNWrapper;
|
|
22
|
+
mod(r: BNWrapper): BNWrapper;
|
|
23
|
+
umod(r: BNWrapper): BNWrapper;
|
|
24
|
+
get bn(): BN;
|
|
25
|
+
toString(base?: number): string;
|
|
26
|
+
toBuffer(opts?: BNWrapperOptions): Buffer;
|
|
27
|
+
toArrayLike(ArrayType: typeof Buffer, endian?: 'le' | 'be', length?: number): Buffer;
|
|
28
|
+
mul(r: BNWrapper): BNWrapper;
|
|
29
|
+
sub(r: BNWrapper): BNWrapper;
|
|
30
|
+
pow(r: BNWrapper): BNWrapper;
|
|
31
|
+
div(r: BNWrapper): BNWrapper;
|
|
32
|
+
modPow(exponent: BNWrapper, modulus: BNWrapper): BNWrapper;
|
|
33
|
+
and(other: BNWrapper | number): BNWrapper;
|
|
34
|
+
neg(): BNWrapper;
|
|
35
|
+
invm(r: BNWrapper): BNWrapper;
|
|
36
|
+
eq(other: BNWrapper): boolean;
|
|
37
|
+
lt(other: BNWrapper): boolean;
|
|
38
|
+
gt(other: BNWrapper): boolean;
|
|
39
|
+
lte(other: BNWrapper): boolean;
|
|
40
|
+
gte(other: BNWrapper): boolean;
|
|
41
|
+
isZero(): boolean;
|
|
42
|
+
isNeg(): boolean;
|
|
43
|
+
isOdd(): boolean;
|
|
44
|
+
isEven(): boolean;
|
|
45
|
+
toSMBigEndian(): Buffer;
|
|
46
|
+
toSM(opts?: BNWrapperOptions): Buffer;
|
|
47
|
+
toScriptNumBuffer(): Buffer;
|
|
48
|
+
cmp(other: BNWrapper): number;
|
|
49
|
+
copy(other: BNWrapper): BNWrapper;
|
|
50
|
+
clone(): BNWrapper;
|
|
51
|
+
}
|
|
52
|
+
export { BNWrapper as BN };
|
|
53
|
+
//# sourceMappingURL=bn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bn.d.ts","sourceRoot":"","sources":["../../../../l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