Skip to content

Commit

Permalink
[gh-2589] add signatories as file suffix. (#2641)
Browse files Browse the repository at this point in the history
* [gh-2589] add signatories as file suffix.

* [gh-2589] remove count and add signatory suffix to file.

---------

Co-authored-by: Feliciss <10203-feliciss@users.noreply.0xacab.org>
  • Loading branch information
feliciss and Feliciss authored Sep 17, 2024
1 parent 8211bdf commit 67a5e35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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

0 comments on commit 67a5e35

Please sign in to comment.