forked from cerc-io/ipld-eth-server
TxOutputs: extract and index pkscript metadata (script type, addresses, #required sigs); TxInputs: outpoint_hash => outpoint_tx_id that references transaction_cids.id
This commit is contained in:
@@ -3,11 +3,10 @@ CREATE TABLE btc.transaction_cids (
|
||||
id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES btc.header_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
index INTEGER NOT NULL,
|
||||
tx_hash VARCHAR(66) NOT NULL,
|
||||
tx_hash VARCHAR(66) NOT NULL UNIQUE,
|
||||
cid TEXT NOT NULL,
|
||||
has_witness BOOL NOT NULL,
|
||||
witness_hash VARCHAR(66),
|
||||
UNIQUE (header_id, tx_hash)
|
||||
segwit BOOL NOT NULL,
|
||||
witness_hash VARCHAR(66)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -3,9 +3,9 @@ CREATE TABLE btc.tx_inputs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
tx_id INTEGER NOT NULL REFERENCES btc.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
index INTEGER NOT NULL,
|
||||
tx_witness BYTEA[],
|
||||
witness BYTEA[],
|
||||
sig_script BYTEA NOT NULL,
|
||||
outpoint_hash VARCHAR(66) NOT NULL,
|
||||
outpoint_tx_id INTEGER NOT NULL REFERENCES btc.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
outpoint_index INTEGER NOT NULL,
|
||||
UNIQUE (tx_id, index)
|
||||
);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE btc.tx_outputs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
tx_id INTEGER NOT NULL REFERENCES btc.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
index INTEGER NOT NULL,
|
||||
value INTEGER NOT NULL,
|
||||
pk_script BYTEA NOT NULL,
|
||||
id SERIAL PRIMARY KEY,
|
||||
tx_id INTEGER NOT NULL REFERENCES btc.transaction_cids (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
index INTEGER NOT NULL,
|
||||
value INTEGER NOT NULL,
|
||||
pk_script BYTEA NOT NULL,
|
||||
script_class INTEGER NOT NULL,
|
||||
addresses VARCHAR(66)[],
|
||||
required_sigs INTEGER NOT NULL,
|
||||
UNIQUE (tx_id, index)
|
||||
);
|
||||
|
||||
|
||||
+24
-14
@@ -78,7 +78,7 @@ CREATE TABLE btc.transaction_cids (
|
||||
index integer NOT NULL,
|
||||
tx_hash character varying(66) NOT NULL,
|
||||
cid text NOT NULL,
|
||||
has_witness boolean NOT NULL,
|
||||
segwit boolean NOT NULL,
|
||||
witness_hash character varying(66)
|
||||
);
|
||||
|
||||
@@ -111,10 +111,9 @@ CREATE TABLE btc.tx_inputs (
|
||||
id integer NOT NULL,
|
||||
tx_id integer NOT NULL,
|
||||
index integer NOT NULL,
|
||||
tx_witness bytea[],
|
||||
sequence integer NOT NULL,
|
||||
script bytea NOT NULL,
|
||||
outpoint_hash character varying(66) NOT NULL,
|
||||
witness bytea[],
|
||||
sig_script bytea NOT NULL,
|
||||
outpoint_tx_id integer NOT NULL,
|
||||
outpoint_index integer NOT NULL
|
||||
);
|
||||
|
||||
@@ -148,7 +147,10 @@ CREATE TABLE btc.tx_outputs (
|
||||
tx_id integer NOT NULL,
|
||||
index integer NOT NULL,
|
||||
value integer NOT NULL,
|
||||
script bytea NOT NULL
|
||||
pk_script bytea NOT NULL,
|
||||
script_class integer NOT NULL,
|
||||
addresses character varying(66)[],
|
||||
required_sigs integer NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -1275,14 +1277,6 @@ ALTER TABLE ONLY btc.header_cids
|
||||
ADD CONSTRAINT header_cids_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids transaction_cids_header_id_tx_hash_key; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_header_id_tx_hash_key UNIQUE (header_id, tx_hash);
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids transaction_cids_pkey; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
@@ -1291,6 +1285,14 @@ ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: transaction_cids transaction_cids_tx_hash_key; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_tx_hash_key UNIQUE (tx_hash);
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs tx_inputs_pkey; Type: CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
@@ -1744,6 +1746,14 @@ ALTER TABLE ONLY btc.transaction_cids
|
||||
ADD CONSTRAINT transaction_cids_header_id_fkey FOREIGN KEY (header_id) REFERENCES btc.header_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs tx_inputs_outpoint_tx_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY btc.tx_inputs
|
||||
ADD CONSTRAINT tx_inputs_outpoint_tx_id_fkey FOREIGN KEY (outpoint_tx_id) REFERENCES btc.transaction_cids(id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: tx_inputs tx_inputs_tx_id_fkey; Type: FK CONSTRAINT; Schema: btc; Owner: -
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user