Skip to content

Commit

Permalink
FixedTxWitnessesSet fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lisicky committed Sep 9, 2024
1 parent f6cb29a commit 624bf30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions rust/src/protocol_types/fixed_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,28 @@ impl FixedTransaction {
}

pub fn add_vkey_witness(&mut self, vkey_witness: &Vkeywitness) {
self.witness_set.add_vkey_witness(vkey_witness.clone());
self.witness_set.add_vkey_witness(vkey_witness);
}

pub fn add_bootstrap_witness(&mut self, bootstrap_witness: &BootstrapWitness) {
self.witness_set.add_bootstrap_witness(bootstrap_witness.clone());
self.witness_set.add_bootstrap_witness(bootstrap_witness);
}

pub fn sign_and_add_vkey_signature(&mut self, private_key: &PrivateKey) -> Result<(), JsError> {
let vkey_witness = make_vkey_witness(&self.tx_hash, private_key);
self.witness_set.add_vkey_witness(vkey_witness);
self.witness_set.add_vkey_witness(&vkey_witness);
Ok(())
}

pub fn sign_and_add_icarus_bootstrap_signature(&mut self, addr: &ByronAddress, private_key: &Bip32PrivateKey) -> Result<(), JsError> {
let bootstrap_witness = make_icarus_bootstrap_witness(&self.tx_hash, addr, private_key);
self.witness_set.add_bootstrap_witness(bootstrap_witness);
self.witness_set.add_bootstrap_witness(&bootstrap_witness);
Ok(())
}

pub fn sign_and_add_daedalus_bootstrap_signature(&mut self, addr: &ByronAddress, private_key: &LegacyDaedalusPrivateKey) -> Result<(), JsError> {
let bootstrap_witness = make_daedalus_bootstrap_witness(&self.tx_hash, addr, private_key);
self.witness_set.add_bootstrap_witness(bootstrap_witness);
self.witness_set.add_bootstrap_witness(&bootstrap_witness);
Ok(())
}
}
10 changes: 5 additions & 5 deletions rust/src/protocol_types/witnesses/fixed_tx_witnesses_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::*;
/// Or get TransactionWitnessSet to read fields.
#[wasm_bindgen]
#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) struct FixedTxWitnessesSet {
pub struct FixedTxWitnessesSet {
pub(crate) raw_parts: TransactionWitnessSetRaw,
pub(crate) tx_witnesses_set: TransactionWitnessSet,
}
Expand All @@ -20,22 +20,22 @@ impl FixedTxWitnessesSet {
self.tx_witnesses_set.clone()
}

pub fn add_vkey_witness(&mut self, vkey_witness: Vkeywitness) {
pub fn add_vkey_witness(&mut self, vkey_witness: &Vkeywitness) {
if self.tx_witnesses_set.vkeys.is_none() {
self.tx_witnesses_set.vkeys = Some(Vkeywitnesses::new());
}
if let Some(vkeys) = &mut self.tx_witnesses_set.vkeys {
vkeys.add(&vkey_witness);
vkeys.add(vkey_witness);
}
self.raw_parts.vkeys = None;
}

pub fn add_bootstrap_witness(&mut self, bootstrap_witness: BootstrapWitness) {
pub fn add_bootstrap_witness(&mut self, bootstrap_witness: &BootstrapWitness) {
if self.tx_witnesses_set.bootstraps.is_none() {
self.tx_witnesses_set.bootstraps = Some(BootstrapWitnesses::new());
}
if let Some(bootstraps) = &mut self.tx_witnesses_set.bootstraps {
bootstraps.add(&bootstrap_witness);
bootstraps.add(bootstrap_witness);
}
self.raw_parts.bootstraps = None;
}
Expand Down

0 comments on commit 624bf30

Please sign in to comment.