mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-03 22:03:06 +00:00
modilfy utxo struct
This commit is contained in:
parent
eb8c128106
commit
4f94dd2595
@ -83,10 +83,12 @@ impl Account {
|
||||
self.balance = new_balance;
|
||||
}
|
||||
|
||||
pub fn add_asset<Asset: Serialize>(&mut self, asset: Asset) -> Result<()> {
|
||||
pub fn add_asset<Asset: Serialize>(&mut self, asset: Asset, amount: u128, privacy_flag: bool) -> Result<()> {
|
||||
let payload_with_asset = UTXOPayload {
|
||||
owner: self.address,
|
||||
asset: serde_json::to_vec(&asset)?,
|
||||
amount,
|
||||
privacy_flag,
|
||||
};
|
||||
|
||||
let asset_utxo = UTXO::create_utxo_from_payload(payload_with_asset);
|
||||
|
||||
@ -6,19 +6,25 @@ use storage::{merkle_tree_public::TreeHashType, nullifier::UTXONullifier, Accoun
|
||||
///Raw asset data
|
||||
pub type Asset = Vec<u8>;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
///Container for raw utxo payload
|
||||
pub struct UTXO {
|
||||
pub hash: TreeHashType,
|
||||
pub owner: AccountId,
|
||||
pub nullifier: Option<UTXONullifier>,
|
||||
pub asset: Asset,
|
||||
// TODO: change to u256
|
||||
pub amount: u128,
|
||||
pub privacy_flag: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UTXOPayload {
|
||||
pub owner: AccountId,
|
||||
pub asset: Asset,
|
||||
// TODO: change to u256
|
||||
pub amount: u128,
|
||||
pub privacy_flag: bool,
|
||||
}
|
||||
|
||||
impl UTXO {
|
||||
@ -36,6 +42,8 @@ impl UTXO {
|
||||
owner: payload_with_asset.owner,
|
||||
nullifier: None,
|
||||
asset: payload_with_asset.asset,
|
||||
amount: payload_with_asset.amount,
|
||||
privacy_flag: payload_with_asset.privacy_flag,
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,6 +93,8 @@ mod tests {
|
||||
name: "Test".to_string(),
|
||||
})
|
||||
.unwrap(),
|
||||
amount: 10,
|
||||
privacy_flag: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -83,6 +83,8 @@ mod tests {
|
||||
UTXOPayload {
|
||||
owner: AccountId::default(),
|
||||
asset: vec![1, 2, 3],
|
||||
amount: 10,
|
||||
privacy_flag: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user