-
Notifications
You must be signed in to change notification settings - Fork 1
/
block.d.ts
56 lines (56 loc) · 2 KB
/
block.d.ts
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
/// <reference types="node" />
/**
* Block
* =====
*
* A block, of course, is a collection of transactions. This class is somewhat
* incompconste at the moment. In the future, it should support the ability to
* check to see if a transaction is in a block (thanks to the magic of merkle
* trees). You will probably never use Yours Bitcoin to create a block, since almost
* everyone will use bitcoind for that. As such, the primary way to use this is
* new Block().fromBuffer(buf), which will parse the block and prepare its insides
* for you to inspect.
*/
import { BlockHeader, BlockHeaderLike } from './block-header';
import { Br } from './br';
import { Bw } from './bw';
import { Struct } from './struct';
import { Tx, TxLike } from './tx';
import { VarInt } from './var-int';
export interface BlockLike {
blockHeader: BlockHeaderLike;
txsVi: string;
txs: TxLike[];
}
export declare class Block extends Struct {
static readonly MAX_BLOCK_SIZE = 1000000;
blockHeader: BlockHeader;
txsVi: VarInt;
txs: Tx[];
constructor(blockHeader?: BlockHeader, txsVi?: VarInt, txs?: Tx[]);
fromJSON(json: BlockLike): this;
toJSON(): BlockLike;
fromBr(br: Br): this;
toBw(bw?: Bw): Bw;
hash(): Buffer;
asyncHash(): Promise<Buffer>;
id(): string;
asyncId(): Promise<string>;
verifyMerkleRoot(): number;
/**
* Sometimes we don't want to parse an entire block into memory. Instead, we
* simply want to iterate through all transactions in the block. That is what
* this method is for. This method returns an efficient iterator which can be
* used in a `for (tx of txs)` construct that returns each tx one at a time
* without first parsing all of them into memory.
*
* @param {Buffer} blockBuf A buffer of a block.
*/
static iterateTxs(blockBuf: Buffer): {
blockHeader: BlockHeader;
txsVi: VarInt;
txsNum: number;
[Symbol.iterator](): Generator<Tx, void, unknown>;
};
}
//# sourceMappingURL=block.d.ts.map