@bsv/wallet-toolbox
Version:
BRC100 conforming wallet, wallet storage and wallet signer components
67 lines • 3.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockChainMigrations = void 0;
class MockChainMigrations {
constructor() {
this.migrations = {};
this.migrations = this.setupMigrations();
}
async getMigrations() {
return Object.keys(this.migrations).sort((a, b) => a.localeCompare(b));
}
getMigrationName(migration) {
return migration;
}
async getMigration(migration) {
return this.migrations[migration];
}
setupMigrations() {
const migrations = {};
migrations['2026-01-01-001 initial mockchain tables'] = {
async up(knex) {
await knex.schema.createTable('mockchain_block_headers', table => {
table.integer('height').primary();
table.string('hash', 64).notNullable().unique();
table.string('previousHash', 64).notNullable();
table.string('merkleRoot', 64).notNullable();
table.integer('version').notNullable().defaultTo(1);
table.integer('time').unsigned().notNullable();
table.integer('bits').unsigned().notNullable();
table.integer('nonce').unsigned().notNullable();
table.string('coinbaseTxid', 64).notNullable();
table.timestamp('created_at').defaultTo(knex.fn.now()).notNullable();
});
await knex.schema.createTable('mockchain_transactions', table => {
table.string('txid', 64).primary();
table.binary('rawTx').notNullable();
table.integer('blockHeight').nullable();
table.integer('blockIndex').nullable();
table.timestamp('created_at').defaultTo(knex.fn.now()).notNullable();
});
await knex.schema.createTable('mockchain_utxos', table => {
table.increments('id').primary();
table.string('txid', 64).notNullable();
table.integer('vout').notNullable();
table.binary('lockingScript').notNullable();
table.bigInteger('satoshis').notNullable();
table.string('scriptHash', 64).notNullable();
table.string('spentByTxid', 64).nullable();
table.boolean('isCoinbase').notNullable().defaultTo(false);
table.integer('blockHeight').nullable();
table.timestamp('created_at').defaultTo(knex.fn.now()).notNullable();
table.unique(['txid', 'vout']);
table.index('scriptHash');
table.index('spentByTxid');
});
},
async down(knex) {
await knex.schema.dropTableIfExists('mockchain_utxos');
await knex.schema.dropTableIfExists('mockchain_transactions');
await knex.schema.dropTableIfExists('mockchain_block_headers');
}
};
return migrations;
}
}
exports.MockChainMigrations = MockChainMigrations;
//# sourceMappingURL=MockChainMigrations.js.map