-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSchema.txt
109 lines (101 loc) · 2.92 KB
/
Schema.txt
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
CREATE TABLE blockheader (
indexnum INT,
blockheight INT UNIQUE,
blockhash TEXT,
time INT,
timeutc TIMESTAMP,
mediantime INT,
epoch INT,
epochsubsidy NUMERIC(10, 0),
blocksubsidy NUMERIC(10, 0),
transactionscount INT,
vincount INT,
vinvalue NUMERIC(15, 0),
voutcount INT,
voutvalue NUMERIC(15, 0),
fees NUMERIC(15, 0),
strippedsize INT,
size INT,
weight INT,
version TEXT,
versionhex TEXT,
merkleroot TEXT,
bits TEXT,
chainwork TEXT,
difficulty TEXT,
nonce TEXT,
coinbasescriptsig TEXT,
sequence TEXT,
extranonce TEXT,
extranoncereversed TEXT,
extranoncedecimal TEXT
);
CREATE TABLE txnheader (
indexnum INT,
blockheight INT,
transactionid TEXT,
transactionindex INT,
iscoinbase BOOLEAN DEFAULT FALSE,
coinbasemsg TEXT,
sequence TEXT,
vincount INT,
vinvalue NUMERIC(15, 0),
voutcount INT,
voutvalue NUMERIC(15, 0),
fees NUMERIC(15, 0),
virtualsize_vb INT,
weight_wu INT,
CONSTRAINT unique_block_txid UNIQUE (blockheight, transactionid)
);
CREATE TABLE inputs (
indexnum INT,
blockheight INT,
transactionindex INT,
transactionid TEXT,
iscoinbase BOOLEAN DEFAULT FALSE,
vin INT,
origintransactionid TEXT,
originvout INT,
coinbasemsg TEXT,
sequence TEXT,
scriptsig TEXT,
scriptwitness TEXT
);
CREATE TABLE outputs (
indexnum INT,
blockheight INT,
transactionindex INT,
transactionid TEXT,
fromcoinbase BOOLEAN DEFAULT FALSE,
vout INT,
address TEXT,
amount NUMERIC(15, 0),
scripttype TEXT,
asm TEXT,
descriptor TEXT,
scripthex TEXT,
isspent BOOLEAN DEFAULT FALSE,
isspendable BOOLEAN DEFAULT TRUE,
spendingblock INT,
spendingtxnid TEXT,
spendingvin INT,
spendingscript TEXT,
spendingwitness TEXT
);
-- Inputs table indexes
CREATE INDEX idx_inputs_blockheight ON inputs (blockheight);
CREATE INDEX idx_inputs_origintransactionid ON inputs (origintransactionid);
CREATE INDEX idx_inputs_originvout ON inputs (originvout);
-- Outputs table indexes
CREATE INDEX idx_outputs_blockheight ON outputs (blockheight);
CREATE INDEX idx_outputs_address ON outputs (address);
CREATE INDEX idx_outputs_vout ON outputs (vout);
CREATE INDEX idx_outputs_transactionid ON outputs (transactionid);
CREATE INDEX idx_outputs_isspendable ON outputs (isspendable);
CREATE INDEX idx_outputs_isspent ON outputs (isspent);
CREATE INDEX idx_outputs_spendingblockheight ON outputs (spendingblock);
CREATE INDEX idx_outputs_spendingtransactionid ON outputs (spendingtxnid);
-- Transactions table indexes
CREATE INDEX idx_txnheader_transactionid ON txnheader (transactionid);
CREATE INDEX idx_txnheader_blockheight ON txnheader (blockheight);
CREATE INDEX idx_txnheader_iscoinbase ON txnheader (iscoinbase);