-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
101 lines (82 loc) · 1.86 KB
/
types.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
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
/**
* @author Michael D. Nath, Kenan Hasanaliyev
* @email [email protected], [email protected]
* @file types.ts
* @desc types.ts outlines all interfaces/typedefs used for handshakes, blocks, transactions, function callbacks, etc.
*/
import { Socket } from "net";
export interface ValidationMessage {
valid: boolean;
error: ErrorMessage;
data: Object;
}
export interface Message {
type: string;
}
export interface ErrorMessage extends Message {
error: string;
}
export interface HelloMessage extends Message {
version: string;
agent: string;
}
export interface HashObjectMessage extends Message {
objectid: string;
}
export interface ObjectMessage extends Message {
object: Block | Transaction;
}
export interface TransactionInput {
outpoint: Outpoint;
sig: string;
}
export interface Outpoint extends Object {
txid: string;
index: number;
}
export interface TransactionOutput {
value: number;
pubkey: string;
}
export interface Transaction extends Object {
type: "transaction";
inputs?: [TransactionInput]; // coinbase txs have no inputs
height?: number; // non-coinbase txs have no height key
outputs: [TransactionOutput];
}
export interface PendingBlock extends Object {
block: Block;
socket: Socket;
txids: Set<String>;
}
export interface Block extends Object {
type: "block";
txids: string[];
created: number;
nonce: string;
previd: string;
miner?: string;
T: string;
note?: string;
}
export type ApplicationObject = Transaction | Block;
export interface VerificationResponse {
exists?: boolean;
valid?: boolean;
msg?: string;
obj?: Transaction;
data?: any;
}
export interface TransactionRequest {
missing: boolean;
txids: Set<string>;
}
export interface ChainTip {
block: Block;
height: number;
}
export interface ChainTipMessage {
type: "chaintip";
blockid: string;
}
export type HashToObjectMap = Map<string, ApplicationObject>;