Add hrp_sapling_extended_spending_key to Parameters trait.
This commit is contained in:
parent
1fd74d0a71
commit
cf2dae8af0
|
@ -163,7 +163,7 @@ mod tests {
|
|||
init::{init_accounts_table, init_data_database},
|
||||
rewind_to_height,
|
||||
},
|
||||
AccountId, BlockDB, WalletDB, NoteId,
|
||||
AccountId, BlockDB, NoteId, WalletDB,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -20,7 +20,7 @@ use zcash_client_backend::{
|
|||
},
|
||||
};
|
||||
|
||||
use crate::{error::SqliteClientError, AccountId, WalletDB, NoteId};
|
||||
use crate::{error::SqliteClientError, AccountId, NoteId, WalletDB};
|
||||
|
||||
pub mod init;
|
||||
pub mod transact;
|
||||
|
@ -284,10 +284,7 @@ pub fn block_height_extrema(
|
|||
.or(Ok(None))
|
||||
}
|
||||
|
||||
pub fn get_tx_height(
|
||||
conn: &WalletDB,
|
||||
txid: TxId,
|
||||
) -> Result<Option<BlockHeight>, rusqlite::Error> {
|
||||
pub fn get_tx_height(conn: &WalletDB, txid: TxId) -> Result<Option<BlockHeight>, rusqlite::Error> {
|
||||
conn.0
|
||||
.query_row(
|
||||
"SELECT block FROM transactions WHERE txid = ?",
|
||||
|
@ -415,9 +412,7 @@ pub fn get_witnesses(
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn get_nullifiers(
|
||||
data: &WalletDB,
|
||||
) -> Result<Vec<(Vec<u8>, AccountId)>, SqliteClientError> {
|
||||
pub fn get_nullifiers(data: &WalletDB) -> Result<Vec<(Vec<u8>, AccountId)>, SqliteClientError> {
|
||||
// Get the nullifiers for the notes we are tracking
|
||||
let mut stmt_fetch_nullifiers = data
|
||||
.0
|
||||
|
|
|
@ -129,32 +129,56 @@ pub trait Parameters: Clone {
|
|||
/// if an activation height has been set.
|
||||
fn activation_height(&self, nu: NetworkUpgrade) -> Option<BlockHeight>;
|
||||
|
||||
/// The coin type for ZEC, as defined by [SLIP 44].
|
||||
///
|
||||
/// [SLIP 44]: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
||||
fn coin_type(&self) -> u32;
|
||||
|
||||
/// Returns the human-readable prefix for Sapling extended full
|
||||
/// viewing keys for the network to which this Parameters value applies.
|
||||
fn hrp_sapling_extended_full_viewing_key(&self) -> &str;
|
||||
|
||||
/// Returns the human-readable prefix for Sapling payment addresses
|
||||
/// viewing keys for the network to which this Parameters value applies.
|
||||
fn hrp_sapling_payment_address(&self) -> &str;
|
||||
|
||||
/// Returns the human-readable prefix for transparent pay-to-public-key-hash
|
||||
/// payment addresses for the network to which this Parameters value applies.
|
||||
fn b58_pubkey_address_prefix(&self) -> [u8; 2];
|
||||
|
||||
/// Returns the human-readable prefix for transparent pay-to-script-hash
|
||||
/// payment addresses for the network to which this Parameters value applies.
|
||||
fn b58_script_address_prefix(&self) -> [u8; 2];
|
||||
|
||||
/// Determines whether the specified network upgrade is active as of the
|
||||
/// provided block height on the network to which this Parameters value applies.
|
||||
fn is_nu_active(&self, nu: NetworkUpgrade, height: BlockHeight) -> bool {
|
||||
self.activation_height(nu).map_or(false, |h| h <= height)
|
||||
}
|
||||
|
||||
/// The coin type for ZEC, as defined by [SLIP 44].
|
||||
///
|
||||
/// [SLIP 44]: https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
||||
fn coin_type(&self) -> u32;
|
||||
|
||||
/// Returns the Bech32-encoded human-readable prefix for Sapling extended spending keys
|
||||
/// the network to which this Parameters value applies.
|
||||
///
|
||||
/// Defined in [ZIP 32].
|
||||
///
|
||||
/// [`ExtendedSpendingKey`]: zcash_primitives::zip32::ExtendedSpendingKey
|
||||
/// [ZIP 32]: https://github.com/zcash/zips/blob/master/zip-0032.rst
|
||||
fn hrp_sapling_extended_spending_key(&self) -> &str;
|
||||
|
||||
/// Returns the Bech32-encoded human-readable prefix for Sapling extended full
|
||||
/// viewing keys for the network to which this Parameters value applies.
|
||||
///
|
||||
/// Defined in [ZIP 32].
|
||||
///
|
||||
/// [`ExtendedFullViewingKey`]: zcash_primitives::zip32::ExtendedFullViewingKey
|
||||
/// [ZIP 32]: https://github.com/zcash/zips/blob/master/zip-0032.rst
|
||||
fn hrp_sapling_extended_full_viewing_key(&self) -> &str;
|
||||
|
||||
/// Returns the Bech32-encoded human-readable prefix for Sapling payment addresses
|
||||
/// viewing keys for the network to which this Parameters value applies.
|
||||
///
|
||||
/// Defined in section 5.6.4 of the [Zcash Protocol Specification].
|
||||
///
|
||||
/// [`PaymentAddress`]: zcash_primitives::primitives::PaymentAddress
|
||||
/// [Zcash Protocol Specification]: https://github.com/zcash/zips/blob/master/protocol/protocol.pdf
|
||||
fn hrp_sapling_payment_address(&self) -> &str;
|
||||
|
||||
/// Returns the Base58Check-encoded human-readable prefix for transparent
|
||||
/// pay-to-public-key-hash payment addresses for the network to which this Parameters value
|
||||
/// applies.
|
||||
///
|
||||
/// [`TransparentAddress::PublicKey`]: zcash_primitives::legacy::TransparentAddress::PublicKey
|
||||
fn b58_pubkey_address_prefix(&self) -> [u8; 2];
|
||||
|
||||
/// Returns the Base58Check-encoded human-readable prefix for transparent pay-to-script-hash
|
||||
/// payment addresses for the network to which this Parameters value applies.
|
||||
///
|
||||
/// [`TransparentAddress::Script`]: zcash_primitives::legacy::TransparentAddress::Script
|
||||
fn b58_script_address_prefix(&self) -> [u8; 2];
|
||||
}
|
||||
|
||||
/// Marker struct for the production network.
|
||||
|
@ -179,6 +203,10 @@ impl Parameters for MainNetwork {
|
|||
constants::mainnet::COIN_TYPE
|
||||
}
|
||||
|
||||
fn hrp_sapling_extended_spending_key(&self) -> &str {
|
||||
constants::mainnet::HRP_SAPLING_EXTENDED_SPENDING_KEY
|
||||
}
|
||||
|
||||
fn hrp_sapling_extended_full_viewing_key(&self) -> &str {
|
||||
constants::mainnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY
|
||||
}
|
||||
|
@ -218,6 +246,10 @@ impl Parameters for TestNetwork {
|
|||
constants::testnet::COIN_TYPE
|
||||
}
|
||||
|
||||
fn hrp_sapling_extended_spending_key(&self) -> &str {
|
||||
constants::testnet::HRP_SAPLING_EXTENDED_SPENDING_KEY
|
||||
}
|
||||
|
||||
fn hrp_sapling_extended_full_viewing_key(&self) -> &str {
|
||||
constants::testnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY
|
||||
}
|
||||
|
@ -256,6 +288,13 @@ impl Parameters for Network {
|
|||
}
|
||||
}
|
||||
|
||||
fn hrp_sapling_extended_spending_key(&self) -> &str {
|
||||
match self {
|
||||
Network::MainNetwork => MAIN_NETWORK.hrp_sapling_extended_spending_key(),
|
||||
Network::TestNetwork => TEST_NETWORK.hrp_sapling_extended_spending_key(),
|
||||
}
|
||||
}
|
||||
|
||||
fn hrp_sapling_extended_full_viewing_key(&self) -> &str {
|
||||
match self {
|
||||
Network::MainNetwork => MAIN_NETWORK.hrp_sapling_extended_full_viewing_key(),
|
||||
|
|
Loading…
Reference in New Issue