Skip to content

Commit

Permalink
Forbid etching below rune activation height (#3523)
Browse files Browse the repository at this point in the history
Don't allow etching if the etching reveal height is below the runes activation
height, otherwise the user would waste funds on an ineffective etching.
  • Loading branch information
casey committed Apr 11, 2024
1 parent 248ab53 commit 26fcf05
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/subcommand/wallet/batch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ impl Batch {

let reveal_height = current_height + u32::from(Runestone::COMMIT_CONFIRMATIONS);

let first_rune_height = Rune::first_rune_height(wallet.chain().into());

ensure!(
reveal_height >= first_rune_height,
"rune reveal height below rune activation height: {reveal_height} < {first_rune_height}",
);

if let Some(terms) = etching.terms {
if let Some((start, end)) = terms.offset.and_then(|range| range.start.zip(range.end)) {
ensure!(
Expand Down
42 changes: 42 additions & 0 deletions tests/wallet/batch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2699,3 +2699,45 @@ fn batch_inscribe_errors_if_pending_etchings() {
)
.run_and_extract_stdout();
}

#[test]
fn forbid_etching_below_rune_activation_height() {
let core = mockcore::builder().build();

let ord = TestServer::spawn_with_server_args(&core, &["--index-runes"], &[]);

create_wallet(&core, &ord);

core.mine_blocks(1);

CommandBuilder::new("--index-runes wallet batch --fee-rate 0 --batch batch.yaml")
.write("inscription.txt", "foo")
.write(
"batch.yaml",
serde_yaml::to_string(&batch::File {
etching: Some(batch::Etching {
divisibility: 0,
rune: SpacedRune {
rune: Rune(RUNE),
spacers: 0,
},
supply: "1".parse().unwrap(),
premine: "1".parse().unwrap(),
symbol: '¢',
terms: None,
turbo: false,
}),
inscriptions: vec![batch::Entry {
file: Some("inscription.txt".into()),
..default()
}],
..default()
})
.unwrap(),
)
.core(&core)
.ord(&ord)
.expected_stderr("error: rune reveal height below rune activation height: 7 < 840000\n")
.expected_exit_code(1)
.run_and_extract_stdout();
}

0 comments on commit 26fcf05

Please sign in to comment.