Create PostgreSQL Tables
We will be using PostgreSQL tables to store the Monero Original data. We will need three tables that are named as follows.
xmo_keyimages: Contains transaction rings and key imagesxmo_outputs: Contains the transaction outputsxmr_xmo_keyimages: Contains the rows ofxmr_keyimageswhose key images appear inxmo_keyimages
-
There is a file called
create_keyimages_table.sqlin thescripts/hardforks/monero-originaldirectory with the following contents.CREATE TABLE xmo_keyimages ( image VARCHAR(64) NOT NULL, id SERIAL PRIMARY KEY, ring_amount BIGINT, ring_indices INTEGER[], block_height INTEGER, UNIQUE(image) ) -
Run the following command in the
scripts/hardforks/monero-originaldirectory to create thexmo_keyimagestable.psql -U postgres -h 127.0.0.1 -W -f create_keyimages_table.sql -
There is a file called
create_outputs_table.sqlin thescripts/hardforks/monero-originaldirectory with the following contents.CREATE TABLE xmo_outputs ( image VARCHAR(64) NOT NULL, id SERIAL PRIMARY KEY, ring_amount BIGINT, ring_indices INTEGER[], block_height INTEGER, UNIQUE(image) ) -
Run the following command in the
scripts/hardforks/monero-originaldirectory to create thexmo_outputstable.psql -U postgres -h 127.0.0.1 -W -f create_outputs_table.sqlNOTE: Alternatively, you can create the
xmo_keyimagesandxmo_outputstables by running the script calledsql_table_creation.shin thescripts/hardforks/monero-originaldirectory. You can run the commandsource sql_table_creation.shand enter the Postgres user password when prompted. -
Run the
populate_xmo_tables.pyscript that is located in thescripts/hardforks/monero-originaldirectory.python3 populate_xmo_tables.pyThis script will query the Monero Original client and populate the
xmo_keyimagesandxmo_outputstables with non-coinbase transactions from block height 1,546,000 to block height 1,784,681. The Monero Original blockchain diverged from the main Monero chain at block height 1,546,000. -
Once the
populate_xmo_tables.pyscript finishes running, you can stop the Monero Original client by pressing Ctrl-D in the CLI window. -
Create the
xmr_xmo_keyimagestable using the following steps. It will contain the subset ofxmr_keyimagesthat corresponds to key images which have appeared both on the main Monero chain and the Monero Original chain.- Run the following commands to enter the
psqlshell.sudo su postgres psql - Run the following query.
CREATE TABLE xmr_xmo_keyimages AS (SELECT xmrk.* FROM xmr_keyimages xmrk INNER JOIN xmo_keyimages xmok ON xmrk.image=xmok.image);
- Run the following commands to enter the