mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-05-13 03:30:05 +00:00
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
use common::HashType;
|
|
use nssa::AccountId;
|
|
|
|
use super::{NativeTokenTransfer, auth_transfer_preparation};
|
|
use crate::{ExecutionFailureKind, PrivacyPreservingAccount};
|
|
|
|
impl NativeTokenTransfer<'_> {
|
|
pub async fn send_deshielded_transfer(
|
|
&self,
|
|
from: AccountId,
|
|
to: AccountId,
|
|
balance_to_move: u128,
|
|
) -> Result<(HashType, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
|
let (instruction_data, program, tx_pre_check) = auth_transfer_preparation(balance_to_move);
|
|
|
|
self.0
|
|
.send_privacy_preserving_tx_with_pre_check(
|
|
vec![
|
|
self.0
|
|
.resolve_private_account(from)
|
|
.ok_or(ExecutionFailureKind::KeyNotFoundError)?,
|
|
PrivacyPreservingAccount::Public(to),
|
|
],
|
|
instruction_data,
|
|
&program.into(),
|
|
tx_pre_check,
|
|
)
|
|
.await
|
|
.map(|(resp, secrets)| {
|
|
let first = secrets
|
|
.into_iter()
|
|
.next()
|
|
.expect("expected sender's secret");
|
|
(resp, first)
|
|
})
|
|
}
|
|
}
|