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:
@@ -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],
|
||||
|
||||
@@ -3,10 +3,11 @@ use byteorder::{LittleEndian, WriteBytesExt};
|
||||
use ff::{PrimeField, PrimeFieldRepr};
|
||||
|
||||
use super::{
|
||||
components::{Amount, Script, TxOut},
|
||||
components::{Amount, TxOut},
|
||||
Transaction, TransactionData, OVERWINTER_VERSION_GROUP_ID, SAPLING_TX_VERSION,
|
||||
SAPLING_VERSION_GROUP_ID,
|
||||
};
|
||||
use legacy::Script;
|
||||
|
||||
const ZCASH_SIGHASH_PERSONALIZATION_PREFIX: &'static [u8; 12] = b"ZcashSigHash";
|
||||
const ZCASH_PREVOUTS_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashPrevoutHash";
|
||||
|
||||
@@ -6,11 +6,8 @@ use sapling_crypto::{
|
||||
redjubjub::PrivateKey,
|
||||
};
|
||||
|
||||
use super::{
|
||||
components::{Amount, Script},
|
||||
sighash::signature_hash,
|
||||
Transaction, TransactionData,
|
||||
};
|
||||
use super::{components::Amount, sighash::signature_hash, Transaction, TransactionData};
|
||||
use legacy::Script;
|
||||
use JUBJUB;
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user