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

[gh-2589] add signatories as file suffix. #2641

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions crates/rooch-types/src/transaction/rooch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ impl PartiallySignedRoochTransaction {
self.data.sender
}

pub fn signatories(&self) -> usize {
self.authenticators.len()
}

pub fn contains_authenticator(&self, authenticator: &BitcoinAuthenticator) -> bool {
self.authenticators
.iter()
Expand Down
15 changes: 14 additions & 1 deletion crates/rooch/src/commands/transaction/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ impl FileOutputData {
}
}

pub fn file_signatory_suffix(&self) -> String {
match self {
FileOutputData::RoochTransactionData(data) => data.sender.to_bech32(),
FileOutputData::SignedRoochTransaction(data) => data.sender().to_bech32(),
FileOutputData::PartiallySignedRoochTransaction(data) => data.signatories().to_string(),
}
}

pub fn file_suffix(&self) -> &str {
match self {
FileOutputData::RoochTransactionData(_) => "rtd",
Expand All @@ -50,7 +58,12 @@ impl FileOutputData {
pub fn default_output_file_path(&self) -> Result<PathBuf> {
let temp_dir = env::temp_dir();
let tx_hash = self.tx_hash();
let file_name = format!("{}.{}", hex::encode(&tx_hash[..8]), self.file_suffix());
let file_name = format!(
"{}.{}.{}",
hex::encode(&tx_hash[..8]),
self.file_signatory_suffix(),
self.file_suffix()
);
Ok(temp_dir.join(file_name))
}
}
Expand Down
Loading