diff --git a/Cargo.lock b/Cargo.lock index 71f7616d5..d4b3a4997 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6452,6 +6452,7 @@ dependencies = [ "blake2b_simd", "bs58", "byteorder", + "core2", "document-features", "getset", "hex", diff --git a/zcash_transparent/Cargo.toml b/zcash_transparent/Cargo.toml index ab4064f61..dad661787 100644 --- a/zcash_transparent/Cargo.toml +++ b/zcash_transparent/Cargo.toml @@ -18,6 +18,7 @@ zcash_address.workspace = true zcash_encoding.workspace = true zcash_protocol.workspace = true zip32.workspace = true +core2.workspace = true # Dependencies exposed in a public API: # (Breaking upgrades to these require a breaking upgrade to this crate.) diff --git a/zcash_transparent/src/address.rs b/zcash_transparent/src/address.rs index 2dfde0e0a..16fb5bfcf 100644 --- a/zcash_transparent/src/address.rs +++ b/zcash_transparent/src/address.rs @@ -1,12 +1,14 @@ //! Support for legacy transparent addresses and scripts. use byteorder::{ReadBytesExt, WriteBytesExt}; -use zcash_address::TryFromRawAddress; -use std::fmt; -use std::io::{self, Read, Write}; -use std::ops::Shl; +use alloc::string::String; +use alloc::vec::Vec; +use core::fmt; +use core::ops::Shl; +use core2::io::{self, Read, Write}; +use zcash_address::TryFromRawAddress; use zcash_encoding::Vector; /// Defined script opcodes. diff --git a/zcash_transparent/src/builder.rs b/zcash_transparent/src/builder.rs index c4392b4e4..420091089 100644 --- a/zcash_transparent/src/builder.rs +++ b/zcash_transparent/src/builder.rs @@ -1,7 +1,8 @@ //! Types and functions for building transparent transaction components. -use std::collections::BTreeMap; -use std::fmt; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; +use core::fmt; use zcash_protocol::value::{BalanceError, ZatBalance as Amount, Zatoshis as NonNegativeAmount}; @@ -287,7 +288,7 @@ impl TxIn { TxIn { prevout, script_sig: (), - sequence: std::u32::MAX, + sequence: u32::MAX, } } } @@ -362,7 +363,7 @@ impl Bundle { }); #[cfg(not(feature = "transparent-inputs"))] - let script_sigs = std::iter::empty::>(); + let script_sigs = core::iter::empty::>(); Ok(Bundle { vin: self diff --git a/zcash_transparent/src/bundle.rs b/zcash_transparent/src/bundle.rs index 3125894de..6366d3b7e 100644 --- a/zcash_transparent/src/bundle.rs +++ b/zcash_transparent/src/bundle.rs @@ -1,12 +1,15 @@ //! Structs representing the components within Zcash transactions. use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; -use zcash_protocol::TxId; -use std::fmt::Debug; -use std::io::{self, Read, Write}; +use alloc::vec::Vec; +use core::fmt::Debug; +use core2::io::{self, Read, Write}; -use zcash_protocol::value::{BalanceError, ZatBalance as Amount, Zatoshis as NonNegativeAmount}; +use zcash_protocol::{ + value::{BalanceError, ZatBalance as Amount, Zatoshis as NonNegativeAmount}, + TxId, +}; use crate::{ address::{Script, TransparentAddress}, diff --git a/zcash_transparent/src/keys.rs b/zcash_transparent/src/keys.rs index 39a0908c6..2306f4796 100644 --- a/zcash_transparent/src/keys.rs +++ b/zcash_transparent/src/keys.rs @@ -1,5 +1,7 @@ //! Transparent key components. +use alloc::string::ToString; +use alloc::vec::Vec; use bip32::{ ChildNumber, ExtendedKey, ExtendedKeyAttrs, ExtendedPrivateKey, ExtendedPublicKey, Prefix, }; @@ -341,7 +343,7 @@ pub(crate) mod private { /// /// [BIP32]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki /// [BIP44]: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki -pub trait IncomingViewingKey: private::SealedChangeLevelKey + std::marker::Sized { +pub trait IncomingViewingKey: private::SealedChangeLevelKey + core::marker::Sized { /// Derives a transparent address at the provided child index. #[allow(deprecated)] fn derive_address( diff --git a/zcash_transparent/src/lib.rs b/zcash_transparent/src/lib.rs index d6feacb9b..dff01212b 100644 --- a/zcash_transparent/src/lib.rs +++ b/zcash_transparent/src/lib.rs @@ -1,5 +1,7 @@ //! # Zcash transparent protocol +#![no_std] + pub mod address; pub mod builder; pub mod bundle; @@ -8,3 +10,6 @@ pub mod sighash; #[cfg(feature = "transparent-inputs")] pub mod keys; + +#[macro_use] +extern crate alloc; diff --git a/zcash_transparent/src/pczt.rs b/zcash_transparent/src/pczt.rs index 4a3cd5106..faf053031 100644 --- a/zcash_transparent/src/pczt.rs +++ b/zcash_transparent/src/pczt.rs @@ -1,6 +1,8 @@ //! PCZT support for transparent Zcash. -use std::collections::BTreeMap; +use alloc::collections::BTreeMap; +use alloc::string::String; +use alloc::vec::Vec; use bip32::ChildNumber; use getset::Getters; diff --git a/zcash_transparent/src/pczt/parse.rs b/zcash_transparent/src/pczt/parse.rs index 40acbe8f5..95bb69a44 100644 --- a/zcash_transparent/src/pczt/parse.rs +++ b/zcash_transparent/src/pczt/parse.rs @@ -1,4 +1,6 @@ -use std::collections::BTreeMap; +use alloc::collections::BTreeMap; +use alloc::string::String; +use alloc::vec::Vec; use bip32::ChildNumber; use zcash_protocol::{value::Zatoshis, TxId}; diff --git a/zcash_transparent/src/pczt/signer.rs b/zcash_transparent/src/pczt/signer.rs index 471f559af..ab682d404 100644 --- a/zcash_transparent/src/pczt/signer.rs +++ b/zcash_transparent/src/pczt/signer.rs @@ -1,4 +1,5 @@ use crate::sighash::SignableInput; +use alloc::vec::Vec; impl super::Input { /// Signs the transparent spend with the given spend authorizing key. diff --git a/zcash_transparent/src/pczt/tx_extractor.rs b/zcash_transparent/src/pczt/tx_extractor.rs index 8805bb61c..5c2e104bd 100644 --- a/zcash_transparent/src/pczt/tx_extractor.rs +++ b/zcash_transparent/src/pczt/tx_extractor.rs @@ -1,3 +1,4 @@ +use alloc::vec::Vec; use zcash_protocol::value::Zatoshis; use crate::{ @@ -57,7 +58,7 @@ impl super::Bundle { Ok(TxIn { prevout, script_sig: script_sig(input)?, - sequence: input.sequence.unwrap_or(std::u32::MAX), + sequence: input.sequence.unwrap_or(u32::MAX), }) }) .collect::, E>>()?; diff --git a/zcash_transparent/src/pczt/updater.rs b/zcash_transparent/src/pczt/updater.rs index 9dcb90248..8d9eb1de2 100644 --- a/zcash_transparent/src/pczt/updater.rs +++ b/zcash_transparent/src/pczt/updater.rs @@ -1,3 +1,5 @@ +use alloc::string::String; +use alloc::vec::Vec; use ripemd::Ripemd160; use sha2::{Digest, Sha256}; diff --git a/zcash_transparent/src/sighash.rs b/zcash_transparent/src/sighash.rs index f53ea19d5..bf5d4d1d5 100644 --- a/zcash_transparent/src/sighash.rs +++ b/zcash_transparent/src/sighash.rs @@ -1,3 +1,4 @@ +use alloc::vec::Vec; use getset::Getters; use zcash_protocol::value::Zatoshis;