Skip to content

Commit

Permalink
Assert etched runestone is correct (#3354)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Mar 23, 2024
1 parent 9a6c0e9 commit 4990542
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/wallet/inscribe/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ impl Batch {

let rune;
let premine;
let runestone;

if let Some(etch) = self.etch {
let mut edicts = Vec::new();
Expand Down Expand Up @@ -455,7 +456,7 @@ impl Batch {
destination = None;
}

let script_pubkey = Runestone {
let inner = Runestone {
cenotaph: false,
claim: None,
default_output: None,
Expand All @@ -476,8 +477,11 @@ impl Batch {
spacers: etch.rune.spacers,
symbol: Some(etch.symbol),
}),
}
.encipher();
};

let script_pubkey = inner.encipher();

runestone = Some(inner);

ensure!(
script_pubkey.len() <= 82,
Expand All @@ -494,6 +498,7 @@ impl Batch {
} else {
premine = 0;
rune = None;
runestone = None;
}

let commit_input = usize::from(self.parent_info.is_some()) + self.reveal_satpoints.len();
Expand Down Expand Up @@ -632,6 +637,18 @@ impl Batch {
let total_fees =
Self::calculate_fee(&unsigned_commit_tx, &utxos) + Self::calculate_fee(&reveal_tx, &utxos);

match (Runestone::from_transaction(&reveal_tx), runestone) {
(Some(actual), Some(expected)) => assert_eq!(
actual, expected,
"commit transaction runestone did not match expected runestone"
),
(Some(_), None) => panic!("commit transaction contained runestone, but none was expected"),
(None, Some(_)) => {
panic!("commit transaction did not contain runestone, but one was expected")
}
(None, None) => {}
}

let rune = rune.map(|(destination, rune, vout)| RuneInfo {
destination: destination.map(|destination| uncheck(&destination)),
location: vout.map(|vout| OutPoint {
Expand Down

0 comments on commit 4990542

Please sign in to comment.