|
|
@ -440,7 +440,7 @@ pub struct WalletTx { |
|
|
|
|
|
|
|
impl WalletTx { |
|
|
|
pub fn serialized_version() -> u64 { |
|
|
|
return 4; |
|
|
|
return 5; |
|
|
|
} |
|
|
|
|
|
|
|
pub fn new(height: i32, datetime: u64, txid: &TxId) -> Self { |
|
|
@ -460,10 +460,9 @@ impl WalletTx { |
|
|
|
|
|
|
|
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> { |
|
|
|
let version = reader.read_u64::<LittleEndian>()?; |
|
|
|
assert!(version <= WalletTx::serialized_version()); |
|
|
|
assert!(version <= WalletTx::serialized_version(), "Version mismatch. Please restore with your Seed"); |
|
|
|
|
|
|
|
let block = reader.read_i32::<LittleEndian>()?; |
|
|
|
|
|
|
|
let datetime = if version >= 4 { |
|
|
|
reader.read_u64::<LittleEndian>()? |
|
|
|
} else { |
|
|
@ -472,23 +471,24 @@ impl WalletTx { |
|
|
|
|
|
|
|
let mut txid_bytes = [0u8; 32]; |
|
|
|
reader.read_exact(&mut txid_bytes)?; |
|
|
|
|
|
|
|
let txid = TxId{0: txid_bytes}; |
|
|
|
|
|
|
|
let notes = Vector::read(&mut reader, |r| SaplingNoteData::read(r))?; |
|
|
|
let utxos = Vector::read(&mut reader, |r| Utxo::read(r))?; |
|
|
|
|
|
|
|
let total_shielded_value_spent = reader.read_u64::<LittleEndian>()?; |
|
|
|
let total_transparent_value_spent = reader.read_u64::<LittleEndian>()?; |
|
|
|
|
|
|
|
// Outgoing metadata was only added in version 2
|
|
|
|
let outgoing_metadata = Vector::read(&mut reader, |r| OutgoingTxMetadata::read(r))?; |
|
|
|
|
|
|
|
let incoming_metadata = Vector::read(&mut reader, |r| IncomingTxMetadata::read(r))?; |
|
|
|
// Read incoming_metadata only if version is 5 or higher
|
|
|
|
let incoming_metadata = if version >= 5 { |
|
|
|
Vector::read(&mut reader, |r| IncomingTxMetadata::read(r))? |
|
|
|
} else { |
|
|
|
vec![] |
|
|
|
}; |
|
|
|
|
|
|
|
let full_tx_scanned = reader.read_u8()? > 0; |
|
|
|
|
|
|
|
Ok(WalletTx{ |
|
|
|
|
|
|
|
Ok(WalletTx { |
|
|
|
block, |
|
|
|
datetime, |
|
|
|
txid, |
|
|
@ -502,6 +502,7 @@ impl WalletTx { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> { |
|
|
|
writer.write_u64::<LittleEndian>(WalletTx::serialized_version())?; |
|
|
|
|
|
|
|