Merge pull request #107 from str4d/transaction-builder-transparent-inputs

Add P2PKH transparent input support to transaction::Builder
This commit is contained in:
str4d 2019-11-13 22:15:55 +00:00 committed by GitHub
commit 67d700feab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 264 additions and 66 deletions

28
Cargo.lock generated
View File

@ -144,6 +144,11 @@ dependencies = [
"ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cc"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.9"
@ -541,6 +546,16 @@ dependencies = [
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ripemd160"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
@ -554,6 +569,14 @@ name = "scopeguard"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "secp256k1"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.9.0"
@ -662,6 +685,8 @@ dependencies = [
"rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"secp256k1 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -697,6 +722,7 @@ dependencies = [
"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101"
"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be"
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120"
"checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c"
@ -740,8 +766,10 @@ dependencies = [
"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
"checksum rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
"checksum ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
"checksum secp256k1 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e0344a794ff109f85547039536028e12f313178ac1545e49fdf16a530d900a7b"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"

View File

@ -25,11 +25,16 @@ log = "0.4"
pairing = { version = "0.15.0", path = "../pairing" }
rand = "0.7"
rand_core = "0.5.1"
ripemd160 = { version = "0.8", optional = true }
secp256k1 = { version = "=0.15.0", optional = true }
sha2 = "0.8"
[dev-dependencies]
hex-literal = "0.2"
rand_xorshift = "0.2"
[features]
transparent-inputs = ["ripemd160", "secp256k1"]
[badges]
maintenance = { status = "actively-developed" }

View File

@ -26,7 +26,7 @@ enum OpCode {
}
/// A serialized script, used inside transparent inputs and outputs of a transaction.
#[derive(Debug, Default)]
#[derive(Clone, Debug, Default)]
pub struct Script(pub Vec<u8>);
impl Script {
@ -38,6 +38,31 @@ impl Script {
pub fn write<W: Write>(&self, mut writer: W) -> io::Result<()> {
Vector::write(&mut writer, &self.0, |w, e| w.write_u8(*e))
}
/// Returns the address that this Script contains, if any.
pub fn address(&self) -> Option<TransparentAddress> {
if self.0.len() == 25
&& self.0[0] == OpCode::Dup as u8
&& self.0[1] == OpCode::Hash160 as u8
&& self.0[2] == 0x14
&& self.0[23] == OpCode::EqualVerify as u8
&& self.0[24] == OpCode::CheckSig as u8
{
let mut hash = [0; 20];
hash.copy_from_slice(&self.0[3..23]);
Some(TransparentAddress::PublicKey(hash))
} else if self.0.len() == 23
&& self.0[0] == OpCode::Hash160 as u8
&& self.0[1] == 0x14
&& self.0[22] == OpCode::Equal as u8
{
let mut hash = [0; 20];
hash.copy_from_slice(&self.0[2..22]);
Some(TransparentAddress::Script(hash))
} else {
None
}
}
}
impl Shl<OpCode> for Script {
@ -151,7 +176,8 @@ mod tests {
0x76, 0xa9, 0x14, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x88, 0xac,
]
)
);
assert_eq!(addr.script().address(), Some(addr));
}
#[test]
@ -163,6 +189,7 @@ mod tests {
0xa9, 0x14, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x87,
]
)
);
assert_eq!(addr.script().address(), Some(addr));
}
}

View File

@ -21,7 +21,7 @@ pub mod primitives;
pub mod prover;
pub mod redjubjub;
pub mod sapling;
mod serialize;
pub mod serialize;
pub mod transaction;
mod util;
pub mod zip32;

View File

@ -24,6 +24,12 @@ use crate::{
JUBJUB,
};
#[cfg(feature = "transparent-inputs")]
use crate::{
legacy::Script,
transaction::components::{OutPoint, TxIn},
};
const DEFAULT_TX_EXPIRY_DELTA: u32 = 20;
/// If there are any shielded inputs, always have at least two shielded outputs, padding
@ -130,6 +136,106 @@ impl SaplingOutput {
}
}
#[cfg(feature = "transparent-inputs")]
struct TransparentInputInfo {
sk: secp256k1::SecretKey,
pubkey: [u8; secp256k1::constants::PUBLIC_KEY_SIZE],
coin: TxOut,
}
#[cfg(feature = "transparent-inputs")]
struct TransparentInputs {
secp: secp256k1::Secp256k1<secp256k1::SignOnly>,
inputs: Vec<TransparentInputInfo>,
}
#[cfg(feature = "transparent-inputs")]
impl Default for TransparentInputs {
fn default() -> Self {
TransparentInputs {
secp: secp256k1::Secp256k1::gen_new(),
inputs: Default::default(),
}
}
}
#[cfg(not(feature = "transparent-inputs"))]
#[derive(Default)]
struct TransparentInputs;
impl TransparentInputs {
#[cfg(feature = "transparent-inputs")]
fn push(
&mut self,
mtx: &mut TransactionData,
sk: secp256k1::SecretKey,
utxo: OutPoint,
coin: TxOut,
) -> Result<(), Error> {
if coin.value.is_negative() {
return Err(Error::InvalidAmount);
}
let pubkey = secp256k1::PublicKey::from_secret_key(&self.secp, &sk).serialize();
match coin.script_pubkey.address() {
Some(TransparentAddress::PublicKey(hash)) => {
use ripemd160::Ripemd160;
use sha2::{Digest, Sha256};
if &hash[..] != &Ripemd160::digest(&Sha256::digest(&pubkey))[..] {
return Err(Error::InvalidAddress);
}
}
_ => return Err(Error::InvalidAddress),
}
mtx.vin.push(TxIn::new(utxo));
self.inputs.push(TransparentInputInfo { sk, pubkey, coin });
Ok(())
}
fn value_sum(&self) -> Amount {
#[cfg(feature = "transparent-inputs")]
{
self.inputs
.iter()
.map(|input| input.coin.value)
.sum::<Amount>()
}
#[cfg(not(feature = "transparent-inputs"))]
{
Amount::zero()
}
}
#[cfg(feature = "transparent-inputs")]
fn apply_signatures(&self, mtx: &mut TransactionData, consensus_branch_id: u32) {
for (i, info) in self.inputs.iter().enumerate() {
sighash.copy_from_slice(&signature_hash_data(
mtx,
consensus_branch_id,
SIGHASH_ALL,
Some((i, &info.coin.script_pubkey, info.coin.value)),
));
let msg = secp256k1::Message::from_slice(&sighash).expect("32 bytes");
let sig = self.secp.sign(&msg, &info.sk);
// Signature has to have "SIGHASH_ALL" appended to it
let mut sig_bytes: Vec<u8> = sig.serialize_der()[..].to_vec();
sig_bytes.extend(&[SIGHASH_ALL as u8]);
// P2PKH scriptSig
mtx.vin[i].script_sig = Script::default() << &sig_bytes[..] << &info.pubkey[..];
}
}
#[cfg(not(feature = "transparent-inputs"))]
fn apply_signatures(&self, _: &mut TransactionData, _: u32) {}
}
/// Metadata about a transaction created by a [`Builder`].
#[derive(Debug, PartialEq)]
pub struct TransactionMetadata {
@ -176,6 +282,7 @@ pub struct Builder<R: RngCore + CryptoRng> {
anchor: Option<Fr>,
spends: Vec<SpendDescriptionInfo>,
outputs: Vec<SaplingOutput>,
transparent_inputs: TransparentInputs,
change_address: Option<(OutgoingViewingKey, PaymentAddress<Bls12>)>,
}
@ -215,6 +322,7 @@ impl<R: RngCore + CryptoRng> Builder<R> {
anchor: None,
spends: vec![],
outputs: vec![],
transparent_inputs: TransparentInputs::default(),
change_address: None,
}
}
@ -273,6 +381,17 @@ impl<R: RngCore + CryptoRng> Builder<R> {
Ok(())
}
/// Adds a transparent coin to be spent in this transaction.
#[cfg(feature = "transparent-inputs")]
pub fn add_transparent_input(
&mut self,
sk: secp256k1::SecretKey,
utxo: OutPoint,
coin: TxOut,
) -> Result<(), Error> {
self.transparent_inputs.push(&mut self.mtx, sk, utxo, coin)
}
/// Adds a transparent address to send funds to.
pub fn add_transparent_output(
&mut self,
@ -320,8 +439,7 @@ impl<R: RngCore + CryptoRng> Builder<R> {
//
// Valid change
let change = self.mtx.value_balance
- self.fee
let change = self.mtx.value_balance - self.fee + self.transparent_inputs.value_sum()
- self
.mtx
.vout
@ -373,7 +491,6 @@ impl<R: RngCore + CryptoRng> Builder<R> {
//
let mut ctx = prover.new_sapling_proving_context();
let anchor = self.anchor.expect("anchor was set if spends were added");
// Pad Sapling outputs
let orig_outputs_len = outputs.len();
@ -390,40 +507,44 @@ impl<R: RngCore + CryptoRng> Builder<R> {
tx_metadata.output_indices.resize(orig_outputs_len, 0);
// Create Sapling SpendDescriptions
for (i, (pos, spend)) in spends.iter().enumerate() {
let proof_generation_key = spend.extsk.expsk.proof_generation_key(&JUBJUB);
if !spends.is_empty() {
let anchor = self.anchor.expect("anchor was set if spends were added");
let mut nullifier = [0u8; 32];
nullifier.copy_from_slice(&spend.note.nf(
&proof_generation_key.to_viewing_key(&JUBJUB),
spend.witness.position,
&JUBJUB,
));
for (i, (pos, spend)) in spends.iter().enumerate() {
let proof_generation_key = spend.extsk.expsk.proof_generation_key(&JUBJUB);
let (zkproof, cv, rk) = prover
.spend_proof(
&mut ctx,
proof_generation_key,
spend.diversifier,
spend.note.r,
spend.alpha,
spend.note.value,
let mut nullifier = [0u8; 32];
nullifier.copy_from_slice(&spend.note.nf(
&proof_generation_key.to_viewing_key(&JUBJUB),
spend.witness.position,
&JUBJUB,
));
let (zkproof, cv, rk) = prover
.spend_proof(
&mut ctx,
proof_generation_key,
spend.diversifier,
spend.note.r,
spend.alpha,
spend.note.value,
anchor,
spend.witness.clone(),
)
.map_err(|()| Error::SpendProof)?;
self.mtx.shielded_spends.push(SpendDescription {
cv,
anchor,
spend.witness.clone(),
)
.map_err(|()| Error::SpendProof)?;
nullifier,
rk,
zkproof,
spend_auth_sig: None,
});
self.mtx.shielded_spends.push(SpendDescription {
cv,
anchor,
nullifier,
rk,
zkproof,
spend_auth_sig: None,
});
// Record the post-randomized spend location
tx_metadata.spend_indices[*pos] = i;
// Record the post-randomized spend location
tx_metadata.spend_indices[*pos] = i;
}
}
// Create Sapling OutputDescriptions
@ -524,6 +645,10 @@ impl<R: RngCore + CryptoRng> Builder<R> {
.map_err(|()| Error::BindingSig)?,
);
// Transparent signatures
self.transparent_inputs
.apply_signatures(&mut self.mtx, consensus_branch_id);
Ok((
self.mtx.freeze().expect("Transaction should be complete"),
tx_metadata,

View File

@ -21,13 +21,17 @@ const PHGR_PROOF_SIZE: usize = (33 + 33 + 65 + 33 + 33 + 33 + 33 + 33);
const ZC_NUM_JS_INPUTS: usize = 2;
const ZC_NUM_JS_OUTPUTS: usize = 2;
#[derive(Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct OutPoint {
hash: [u8; 32],
n: u32,
}
impl OutPoint {
pub fn new(hash: [u8; 32], n: u32) -> Self {
OutPoint { hash, n }
}
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
let mut hash = [0; 32];
reader.read_exact(&mut hash)?;
@ -44,11 +48,20 @@ impl OutPoint {
#[derive(Debug)]
pub struct TxIn {
pub prevout: OutPoint,
script_sig: Script,
pub script_sig: Script,
pub sequence: u32,
}
impl TxIn {
#[cfg(feature = "transparent-inputs")]
pub fn new(prevout: OutPoint) -> Self {
TxIn {
prevout,
script_sig: Script::default(),
sequence: std::u32::MAX,
}
}
pub fn read<R: Read>(mut reader: &mut R) -> io::Result<Self> {
let prevout = OutPoint::read(&mut reader)?;
let script_sig = Script::read(&mut reader)?;
@ -68,7 +81,7 @@ impl TxIn {
}
}
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct TxOut {
pub value: Amount,
pub script_pubkey: Script,

View File

@ -154,7 +154,7 @@ pub fn signature_hash_data(
tx: &TransactionData,
consensus_branch_id: u32,
hash_type: u32,
transparent_input: Option<(usize, Script, Amount)>,
transparent_input: Option<(usize, &Script, Amount)>,
) -> Vec<u8> {
let sigversion = SigHashVersion::from_tx(tx);
match sigversion {
@ -232,7 +232,7 @@ pub fn signature_hash(
tx: &Transaction,
consensus_branch_id: u32,
hash_type: u32,
transparent_input: Option<(usize, Script, Amount)>,
transparent_input: Option<(usize, &Script, Amount)>,
) -> Vec<u8> {
signature_hash_data(tx, consensus_branch_id, hash_type, transparent_input)
}

View File

@ -212,7 +212,7 @@ fn tx_write_rejects_unexpected_binding_sig() {
fn zip_0143() {
struct TestVector {
tx: Vec<u8>,
script_code: Vec<u8>,
script_code: Script,
transparent_input: Option<u32>,
hash_type: u32,
amount: i64,
@ -229,7 +229,7 @@ fn zip_0143() {
0xb2, 0x83, 0x5a, 0x08, 0x05, 0x75, 0x02, 0x00, 0x02, 0x51, 0x51, 0x48, 0x1c, 0xdd,
0x86, 0xb3, 0xcc, 0x43, 0x18, 0x00,
],
script_code: vec![0x6a, 0x00, 0x00, 0x00, 0x63, 0xac, 0x53],
script_code: Script(vec![0x6a, 0x00, 0x00, 0x00, 0x63, 0xac, 0x53]),
transparent_input: None,
hash_type: 1,
amount: 1672704339313879,
@ -518,7 +518,7 @@ fn zip_0143() {
0xb1, 0xfa, 0x45, 0xad, 0x61, 0xce, 0x9a, 0x1c, 0x47, 0x27, 0xb7, 0xaa, 0xa5, 0x35,
0x62, 0xf5, 0x23, 0xe7, 0x39, 0x52,
],
script_code: vec![0x53],
script_code: Script(vec![0x53]),
transparent_input: Some(1),
hash_type: 3,
amount: 365293780364847,
@ -678,7 +678,7 @@ fn zip_0143() {
0x62, 0x91, 0x85, 0x00, 0x2c, 0x72, 0xc0, 0x12, 0xc4, 0x14, 0xd2, 0x38, 0x2a, 0x6d,
0x47, 0xc7, 0xb3, 0xde, 0xab, 0xa7,
],
script_code: vec![0xac, 0x00],
script_code: Script(vec![0xac, 0x00]),
transparent_input: Some(0),
hash_type: 3,
amount: 711752082734717,
@ -960,7 +960,7 @@ fn zip_0143() {
0xce, 0x1f, 0xca, 0x2c, 0x63, 0xfe, 0x06, 0xb7, 0x98, 0x9d, 0x58, 0x4f, 0xa7, 0xd7,
0x82, 0xa8, 0x8c, 0x1e, 0x7d, 0x64, 0xb6, 0xfb, 0xf5, 0x5e, 0x35,
],
script_code: vec![0x6a, 0x53, 0x53, 0x63],
script_code: Script(vec![0x6a, 0x53, 0x53, 0x63]),
transparent_input: None,
hash_type: 1,
amount: 379068098637835,
@ -1119,7 +1119,7 @@ fn zip_0143() {
0xc1, 0xc4, 0xf2, 0xca, 0xcd, 0xa3, 0x0b, 0xdb, 0x69, 0x30, 0x65, 0x3c, 0x0c, 0xc4,
0x48, 0x6e, 0x60, 0xe8, 0x9f, 0xa8, 0x49, 0xb3,
],
script_code: vec![0x53, 0x52],
script_code: Script(vec![0x53, 0x52]),
transparent_input: Some(0),
hash_type: 3,
amount: 1437866676382615,
@ -1139,7 +1139,7 @@ fn zip_0143() {
0x08, 0xf0, 0x83, 0x05, 0x00, 0x09, 0x63, 0x6a, 0x52, 0x63, 0x51, 0x63, 0x00, 0x6a,
0xac, 0x9a, 0xbc, 0xef, 0x2a, 0x99, 0x08, 0x73, 0x19, 0x00,
],
script_code: vec![0x63],
script_code: Script(vec![0x63]),
transparent_input: None,
hash_type: 1,
amount: 1993227025071196,
@ -1162,7 +1162,7 @@ fn zip_0143() {
0x87, 0x01, 0xff, 0x01, 0x86, 0xd2, 0x6f, 0xee, 0x28, 0xca, 0x06, 0x00, 0x01, 0xac,
0x5a, 0xa7, 0x27, 0xab, 0x79, 0x85, 0xda, 0x0e, 0x00,
],
script_code: vec![0x65, 0x53, 0x51],
script_code: Script(vec![0x65, 0x53, 0x51]),
transparent_input: Some(1),
hash_type: 130,
amount: 449567650863240,
@ -1444,7 +1444,7 @@ fn zip_0143() {
0xba, 0xfe, 0xc8, 0x84, 0x0c, 0x2d, 0x25, 0x5b, 0xf5, 0xad, 0x61, 0xc4, 0x60, 0xf9,
0x8f, 0xeb, 0x82, 0xa1, 0x0f, 0xa1, 0xc0,
],
script_code: vec![0x65, 0x6a, 0x65, 0x51, 0x52, 0x65, 0x63],
script_code: Script(vec![0x65, 0x6a, 0x65, 0x51, 0x52, 0x65, 0x63]),
transparent_input: None,
hash_type: 1,
amount: 1712463999734827,
@ -1602,7 +1602,7 @@ fn zip_0143() {
0xd9, 0xa9, 0xd9, 0xf5, 0x4f, 0xb2, 0xfe, 0x8f, 0x9f, 0x05, 0xcd, 0x11, 0x1e, 0xe4,
0x6c, 0x47, 0x10, 0xf6, 0xf6, 0x3a, 0x62, 0x69, 0x45, 0x57,
],
script_code: vec![0x53, 0x52, 0x00],
script_code: Script(vec![0x53, 0x52, 0x00]),
transparent_input: Some(1),
hash_type: 1,
amount: 1564816348934332,
@ -1885,7 +1885,7 @@ fn zip_0143() {
0x54, 0xa7, 0x89, 0x73, 0x5b, 0x03, 0x49, 0xc4, 0xd5, 0x1c, 0x88, 0x9d, 0x08, 0x95,
0x2d, 0xdd, 0x54, 0x88, 0xbe, 0x95, 0x56, 0x05, 0x94, 0xe6,
],
script_code: vec![0x52, 0x63, 0x53, 0x51, 0x65],
script_code: Script(vec![0x52, 0x63, 0x53, 0x51, 0x65]),
transparent_input: Some(0),
hash_type: 2,
amount: 483959951916902,
@ -1903,7 +1903,7 @@ fn zip_0143() {
let transparent_input = if let Some(n) = tv.transparent_input {
Some((
n as usize,
Script(tv.script_code),
&tv.script_code,
Amount::from_nonnegative_i64(tv.amount).unwrap(),
))
} else {
@ -1921,7 +1921,7 @@ fn zip_0143() {
fn zip_0243() {
struct TestVector {
tx: Vec<u8>,
script_code: Vec<u8>,
script_code: Script,
transparent_input: Option<u32>,
hash_type: u32,
amount: i64,
@ -2229,7 +2229,7 @@ fn zip_0243() {
0xe4, 0x62, 0xef, 0xf9, 0xba, 0x8b, 0x3f, 0x4b, 0xfa, 0xa1, 0x30, 0x0c, 0x26, 0x92,
0x5a, 0x87,
],
script_code: vec![0x63],
script_code: Script(vec![0x63]),
transparent_input: None,
hash_type: 1,
amount: 1969273897303781,
@ -2462,7 +2462,7 @@ fn zip_0243() {
0xed, 0x6a, 0x9f, 0x08, 0x46, 0x4d, 0x56, 0x55, 0x93, 0xe1, 0xa6, 0x3b, 0x93, 0x85,
0x36, 0xb4, 0x92, 0x44, 0xe9, 0x7d,
],
script_code: vec![],
script_code: Script(vec![]),
transparent_input: Some(1),
hash_type: 2,
amount: 652655344020909,
@ -3048,7 +3048,7 @@ fn zip_0243() {
0x76, 0xc5, 0x3b, 0x4d, 0xf7, 0x95, 0x39, 0x81, 0xd5, 0x5a, 0x96, 0xa6, 0xdc, 0xff,
0x99, 0x04, 0xa9, 0x08, 0x42, 0xe5, 0xba, 0xfe, 0xc8, 0x84, 0x0c, 0x2d,
],
script_code: vec![0x53, 0x63, 0x63, 0x51, 0xac, 0x00, 0x51],
script_code: Script(vec![0x53, 0x63, 0x63, 0x51, 0xac, 0x00, 0x51]),
transparent_input: None,
hash_type: 1,
amount: 1345602751504862,
@ -3369,7 +3369,7 @@ fn zip_0243() {
0xde, 0x7f, 0x8e, 0x6a, 0x5c, 0x62, 0xa7, 0x77, 0xd1, 0x75, 0x00, 0x2a, 0x13, 0x7d,
0xe8, 0x5b, 0x88,
],
script_code: vec![],
script_code: Script(vec![]),
transparent_input: None,
hash_type: 1,
amount: 1039204199089370,
@ -3519,7 +3519,7 @@ fn zip_0243() {
0xb5, 0x58, 0x02, 0x9a, 0x36, 0x02, 0x4d, 0x2e, 0x79, 0x0f, 0xc6, 0xfd, 0x66, 0x7f,
0x17, 0x6e, 0x0a, 0xa9, 0x9d, 0xd1, 0xd7, 0x2b, 0x57,
],
script_code: vec![0x6a, 0x51, 0x65, 0xac],
script_code: Script(vec![0x6a, 0x51, 0x65, 0xac]),
transparent_input: None,
hash_type: 1,
amount: 691732482992802,
@ -3919,7 +3919,7 @@ fn zip_0243() {
0x30, 0x3a, 0x3a, 0xb9, 0xbb, 0x2e, 0xe3, 0x79, 0xb9, 0xaf, 0xcd, 0x1f, 0x6a, 0x3c,
0xb9, 0x00, 0x0b, 0xb1, 0x4e,
],
script_code: vec![0x53, 0x63, 0x63, 0xac, 0x63, 0x52],
script_code: Script(vec![0x53, 0x63, 0x63, 0xac, 0x63, 0x52]),
transparent_input: None,
hash_type: 1,
amount: 1152393991505765,
@ -4083,7 +4083,7 @@ fn zip_0243() {
0x53, 0xf1, 0xd0, 0xc8, 0x65, 0xa9, 0x4a, 0xa4, 0x56, 0xdc, 0xd1, 0x8a, 0x39, 0xe2,
0xf5, 0x85, 0xd9, 0xbe, 0xa8,
],
script_code: vec![0x63, 0x00, 0x6a, 0x53, 0x63, 0x6a, 0xac, 0x00],
script_code: Script(vec![0x63, 0x00, 0x6a, 0x53, 0x63, 0x6a, 0xac, 0x00]),
transparent_input: None,
hash_type: 1,
amount: 1788797765223798,
@ -4681,7 +4681,7 @@ fn zip_0243() {
0x31, 0xbd, 0x7c, 0x52, 0x22, 0xb6, 0x70, 0x61, 0x6e, 0x4b, 0x6c, 0xa8, 0xa2, 0x35,
0x50, 0xca, 0xd8, 0xac, 0x0d, 0xdb, 0x76, 0x45, 0xe2, 0xb9, 0x71, 0x3b, 0xe7,
],
script_code: vec![0x6a, 0x00, 0x00, 0x65, 0x53, 0xac, 0x63, 0x53, 0x63],
script_code: Script(vec![0x6a, 0x00, 0x00, 0x65, 0x53, 0xac, 0x63, 0x53, 0x63]),
transparent_input: None,
hash_type: 1,
amount: 1871432121379810,
@ -5190,7 +5190,7 @@ fn zip_0243() {
0x1b, 0x48, 0x09, 0x8e, 0xba, 0x2c, 0x2e, 0xc2, 0x0a, 0x0a, 0xc0, 0x44, 0x3b, 0xa8,
0xe9, 0x48, 0x7b, 0xcf, 0x7d,
],
script_code: vec![0xac, 0x53, 0x63, 0x52, 0x6a, 0x51, 0xac],
script_code: Script(vec![0xac, 0x53, 0x63, 0x52, 0x6a, 0x51, 0xac]),
transparent_input: None,
hash_type: 1,
amount: 1501997449504444,
@ -5380,7 +5380,7 @@ fn zip_0243() {
0xfb, 0x34, 0x1e, 0xf5, 0xff, 0xb4, 0x2b, 0xc2, 0xab, 0xc5, 0x08, 0xff, 0x23, 0x12,
0x48, 0xf2, 0xc2, 0xdc, 0x15, 0x77, 0x0d, 0x33, 0x72, 0x2b, 0x9c, 0x9d, 0xae,
],
script_code: vec![0xac, 0x65],
script_code: Script(vec![0xac, 0x65]),
transparent_input: Some(0),
hash_type: 3,
amount: 391892287957268,
@ -5398,7 +5398,7 @@ fn zip_0243() {
let transparent_input = if let Some(n) = tv.transparent_input {
Some((
n as usize,
Script(tv.script_code),
&tv.script_code,
Amount::from_nonnegative_i64(tv.amount).unwrap(),
))
} else {