diff --git a/src/index.rs b/src/index.rs index af13f9dbb9..4b5aaeec66 100644 --- a/src/index.rs +++ b/src/index.rs @@ -377,6 +377,49 @@ impl Index { Self::set_statistic(&mut statistics, Statistic::Schema, SCHEMA_VERSION)?; } + if settings.index_runes() && settings.chain() == Chain::Mainnet { + let rune = Rune(2055900680524219742); + + let id = RuneId { block: 1, tx: 0 }; + let etching = Txid::all_zeros(); + + tx.open_table(RUNE_TO_RUNE_ID)? + .insert(rune.store(), id.store())?; + + let mut statistics = tx.open_table(STATISTIC_TO_COUNT)?; + + Self::set_statistic(&mut statistics, Statistic::Runes, 1)?; + + tx.open_table(RUNE_ID_TO_RUNE_ENTRY)?.insert( + id.store(), + RuneEntry { + block: id.block, + burned: 0, + divisibility: 0, + etching, + terms: Some(Terms { + amount: Some(1), + cap: Some(u128::MAX), + height: ( + Some((SUBSIDY_HALVING_INTERVAL * 4).into()), + Some((SUBSIDY_HALVING_INTERVAL * 5).into()), + ), + offset: (None, None), + }), + mints: 0, + number: 0, + premine: 0, + spaced_rune: SpacedRune { rune, spacers: 128 }, + symbol: Some('\u{29C9}'), + timestamp: 0, + } + .store(), + )?; + + tx.open_table(TRANSACTION_ID_TO_RUNE)? + .insert(&etching.store(), rune.store())?; + } + tx.commit()?; database diff --git a/src/runes.rs b/src/runes.rs index 5d4664c33f..3919273fb3 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -5386,4 +5386,47 @@ mod tests { context.assert_runes([], []); } + + #[test] + fn genesis_rune() { + assert_eq!( + Chain::Mainnet.first_rune_height(), + SUBSIDY_HALVING_INTERVAL * 4, + ); + + Context::builder() + .chain(Chain::Mainnet) + .arg("--index-runes") + .build() + .assert_runes( + [( + RuneId { block: 1, tx: 0 }, + RuneEntry { + block: 1, + burned: 0, + divisibility: 0, + etching: Txid::all_zeros(), + mints: 0, + number: 0, + premine: 0, + spaced_rune: SpacedRune { + rune: Rune(2055900680524219742), + spacers: 128, + }, + symbol: Some('\u{29C9}'), + terms: Some(Terms { + amount: Some(1), + cap: Some(u128::MAX), + height: ( + Some((SUBSIDY_HALVING_INTERVAL * 4).into()), + Some((SUBSIDY_HALVING_INTERVAL * 5).into()), + ), + offset: (None, None), + }), + timestamp: 0, + }, + )], + [], + ); + } }