fix: fix 3

This commit is contained in:
Oleksandr Pravdyvyi 2024-12-30 08:44:26 +02:00
parent 637adf9d22
commit 0b0b3d7cd6
2 changed files with 15 additions and 14 deletions

View File

@ -217,18 +217,13 @@ impl NodeCore {
pub async fn transfer_utxo_private(
&self,
utxo: UTXO,
commitment_in: [u8; 32],
receivers: Vec<(u128, AccountAddress)>,
) -> (Transaction, Vec<(AccountAddress, [u8; 32])>) {
let acc_map_read_guard = self.storage.read().await;
let accout = acc_map_read_guard.acc_map.get(&utxo.owner).unwrap();
let commitment_in = {
let guard = self.storage.write().await;
guard.utxo_commitments_store.get_tx(utxo.hash).unwrap().hash
};
let nullifier = generate_nullifiers(
&utxo,
&accout
@ -460,10 +455,11 @@ impl NodeCore {
pub async fn send_private_send_tx(
&self,
utxo: UTXO,
comm_hash: [u8; 32],
receivers: Vec<(u128, AccountAddress)>,
) -> Result<(SendTxResponse, Vec<([u8; 32], [u8; 32])>)> {
let point_before_prove = std::time::Instant::now();
let (tx, utxo_hashes) = self.transfer_utxo_private(utxo, receivers).await;
let (tx, utxo_hashes) = self.transfer_utxo_private(utxo, comm_hash, receivers).await;
let point_after_prove = std::time::Instant::now();
let timedelta = (point_after_prove - point_before_prove).as_millis();
@ -560,7 +556,7 @@ impl NodeCore {
{
let acc_map_read_guard = self.storage.read().await;
let acc = acc_map_read_guard.acc_map.get(&acc_addr).unwrap();;
let acc = acc_map_read_guard.acc_map.get(&acc_addr).unwrap();
info!("New acconut public balance is {:?}", acc.balance);
};
@ -593,9 +589,8 @@ impl NodeCore {
///Mint utxo, privately send it to another user
pub async fn subscenario_3(&mut self) {
let acc_addr = self.create_new_account().await;
let acc_addr_rec = self.create_new_account().await;
let (resp, _, new_utxo_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
let (resp, new_utxo_hash, comm_gen_hash) = self.send_private_mint_tx(acc_addr, 100).await.unwrap();
info!("Response for mint private is {resp:?}");
info!("Awaiting new blocks");
@ -613,8 +608,10 @@ impl NodeCore {
.clone()
};
let acc_addr_rec = self.create_new_account().await;
let (resp, new_utxo_hashes) = self
.send_private_send_tx(new_utxo, vec![(100, acc_addr_rec)])
.send_private_send_tx(new_utxo, comm_gen_hash, vec![(100, acc_addr_rec)])
.await
.unwrap();
info!("Response for send deshielded is {resp:?}");

View File

@ -27,8 +27,9 @@ pub fn prove_send_utxo(
owners_parts: Vec<(u128, AccountAddress)>,
) -> (Vec<(UTXO, AccountAddress)>, Receipt) {
let mut builder = ExecutorEnv::builder();
let utxo_payload = spent_utxo.into_payload();
builder.write(&spent_utxo).unwrap();
builder.write(&utxo_payload).unwrap();
builder.write(&owners_parts).unwrap();
let env = builder.build().unwrap();
@ -62,10 +63,11 @@ pub fn prove_send_utxo_shielded(
amount,
privacy_flag: true,
});
let utxo_payload = temp_utxo_to_spend.into_payload();
let mut builder = ExecutorEnv::builder();
builder.write(&temp_utxo_to_spend).unwrap();
builder.write(&utxo_payload).unwrap();
builder.write(&owners_parts).unwrap();
let env = builder.build().unwrap();
@ -141,7 +143,9 @@ pub fn execute_send_utxo(
) -> (UTXO, Vec<(UTXO, AccountAddress)>) {
let mut builder = ExecutorEnv::builder();
builder.write(&spent_utxo).unwrap();
let utxo_payload = spent_utxo.into_payload();
builder.write(&utxo_payload).unwrap();
builder.write(&owners_parts).unwrap();
let env = builder.build().unwrap();