Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert etched runestone #3354

Merged
merged 4 commits into from
Mar 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading