Script opcode and data support

Overrides the shift-left operator for pushing opcodes onto the Script,
matching the notation used in zcashd.
This commit is contained in:
Jack Grigg
2019-05-24 12:30:14 +01:00
parent 1862354ea6
commit dab3c002b7
5 changed files with 111 additions and 21 deletions

View File

@@ -7,7 +7,7 @@ use sapling_crypto::{
};
use std::io::{self, Read, Write};
use serialize::Vector;
use legacy::Script;
use JUBJUB;
// π_A + π_B + π_C
@@ -58,20 +58,6 @@ impl Amount {
}
}
#[derive(Debug)]
pub struct Script(pub Vec<u8>);
impl Script {
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
let script = Vector::read(&mut reader, |r| r.read_u8())?;
Ok(Script(script))
}
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
Vector::write(&mut writer, &self.0, |w, e| w.write_u8(*e))
}
}
#[derive(Debug)]
pub struct OutPoint {
hash: [u8; 32],