| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- use std::io;
- use super::TransactionOutput;
- use crate::{
- crypto::{keypair::PublicKey, spend_proof::SpendRevealedValues, Proof},
- error::Result,
- impl_vec,
- serial::{Decodable, Encodable, VarInt},
- types::{DrkTokenId, DrkValueBlind},
- };
- pub struct PartialTransaction {
- pub clear_inputs: Vec<PartialTransactionClearInput>,
- pub inputs: Vec<PartialTransactionInput>,
- pub outputs: Vec<TransactionOutput>,
- }
- pub struct PartialTransactionClearInput {
- pub value: u64,
- pub token_id: DrkTokenId,
- pub value_blind: DrkValueBlind,
- pub token_blind: DrkValueBlind,
- pub signature_public: PublicKey,
- }
- pub struct PartialTransactionInput {
- pub spend_proof: Proof,
- pub revealed: SpendRevealedValues,
- }
- impl Encodable for PartialTransaction {
- fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
- let mut len = 0;
- len += self.clear_inputs.encode(&mut s)?;
- len += self.inputs.encode(&mut s)?;
- len += self.outputs.encode(s)?;
- Ok(len)
- }
- }
- impl Decodable for PartialTransaction {
- fn decode<D: io::Read>(mut d: D) -> Result<Self> {
- Ok(Self {
- clear_inputs: Decodable::decode(&mut d)?,
- inputs: Decodable::decode(&mut d)?,
- outputs: Decodable::decode(d)?,
- })
- }
- }
- impl Encodable for PartialTransactionClearInput {
- fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
- let mut len = 0;
- len += self.value.encode(&mut s)?;
- len += self.token_id.encode(&mut s)?;
- len += self.value_blind.encode(&mut s)?;
- len += self.token_blind.encode(&mut s)?;
- len += self.signature_public.encode(&mut s)?;
- Ok(len)
- }
- }
- impl Decodable for PartialTransactionClearInput {
- fn decode<D: io::Read>(mut d: D) -> Result<Self> {
- Ok(Self {
- value: Decodable::decode(&mut d)?,
- token_id: Decodable::decode(&mut d)?,
- value_blind: Decodable::decode(&mut d)?,
- token_blind: Decodable::decode(&mut d)?,
- signature_public: Decodable::decode(&mut d)?,
- })
- }
- }
- impl Encodable for PartialTransactionInput {
- fn encode<S: io::Write>(&self, mut s: S) -> Result<usize> {
- let mut len = 0;
- len += self.spend_proof.encode(&mut s)?;
- len += self.revealed.encode(s)?;
- Ok(len)
- }
- }
- impl Decodable for PartialTransactionInput {
- fn decode<D: io::Read>(mut d: D) -> Result<Self> {
- Ok(Self { spend_proof: Decodable::decode(&mut d)?, revealed: Decodable::decode(d)? })
- }
- }
- impl_vec!(PartialTransactionClearInput);
- impl_vec!(PartialTransactionInput);
|