Skip to content

Commit

Permalink
Rename arm in Destination from Address to PublicKeyHash
Browse files Browse the repository at this point in the history
  • Loading branch information
TheQuantumPhysicist committed Feb 2, 2024
1 parent a5e0a6f commit 48eba63
Show file tree
Hide file tree
Showing 28 changed files with 70 additions and 65 deletions.
8 changes: 4 additions & 4 deletions api-server/scanner-lib/src/blockchain_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ async fn update_tables_from_block_reward<T: ApiServerStorageWrite>(
}
TxOutput::Transfer(output_value, destination)
| TxOutput::LockThenTransfer(output_value, destination, _) => match destination {
Destination::PublicKey(_) | Destination::Address(_) => {
Destination::PublicKey(_) | Destination::PublicKeyHash(_) => {
let address = Address::<Destination>::new(&chain_config, destination)
.expect("Unable to encode destination");
match output_value {
Expand Down Expand Up @@ -812,7 +812,7 @@ async fn update_tables_from_transaction_inputs<T: ApiServerStorageWrite>(
Destination::AnyoneCanSpend
| Destination::ClassicMultisig(_)
| Destination::ScriptHash(_) => {}
Destination::PublicKey(_) | Destination::Address(_) => {
Destination::PublicKey(_) | Destination::PublicKeyHash(_) => {
let address =
Address::<Destination>::new(&chain_config, &destination)
.expect("Unable to encode destination");
Expand All @@ -837,7 +837,7 @@ async fn update_tables_from_transaction_inputs<T: ApiServerStorageWrite>(
Destination::AnyoneCanSpend
| Destination::ClassicMultisig(_)
| Destination::ScriptHash(_) => {}
Destination::PublicKey(_) | Destination::Address(_) => {
Destination::PublicKey(_) | Destination::PublicKeyHash(_) => {
let address =
Address::<Destination>::new(&chain_config, &destination)
.expect("Unable to encode destination");
Expand Down Expand Up @@ -1052,7 +1052,7 @@ async fn update_tables_from_transaction_outputs<T: ApiServerStorageWrite>(
}
TxOutput::Transfer(output_value, destination)
| TxOutput::LockThenTransfer(output_value, destination, _) => match destination {
Destination::PublicKey(_) | Destination::Address(_) => {
Destination::PublicKey(_) | Destination::PublicKeyHash(_) => {
let address = Address::<Destination>::new(&chain_config, destination)
.expect("Unable to encode destination");

Expand Down
10 changes: 5 additions & 5 deletions api-server/stack-test-suite/tests/v1/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn address_not_found(#[case] seed: Seed) {
let chain_config = create_unit_test_config();

let (_, public_key) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let destination = Destination::Address(PublicKeyHash::from(&public_key));
let destination = Destination::PublicKeyHash(PublicKeyHash::from(&public_key));
let address = Address::<Destination>::new(&chain_config, &destination).unwrap();

let (task, response) = spawn_webserver(&format!("/api/v1/address/{}", address.get())).await;
Expand Down Expand Up @@ -85,7 +85,7 @@ async fn multiple_outputs_to_single_address(#[case] seed: Seed) {
let (alice_sk, alice_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let alice_destination = Destination::Address(PublicKeyHash::from(&alice_pk));
let alice_destination = Destination::PublicKeyHash(PublicKeyHash::from(&alice_pk));
let alice_address =
Address::<Destination>::new(&chain_config, &alice_destination).unwrap();
let mut alice_balance = Amount::from_atoms(1_000_000);
Expand All @@ -94,7 +94,7 @@ async fn multiple_outputs_to_single_address(#[case] seed: Seed) {
let (_bob_sk, bob_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let bob_destination = Destination::Address(PublicKeyHash::from(&bob_pk));
let bob_destination = Destination::PublicKeyHash(PublicKeyHash::from(&bob_pk));
let bob_address =
Address::<Destination>::new(&chain_config, &bob_destination).unwrap();
let mut bob_balance = Amount::ZERO;
Expand Down Expand Up @@ -309,7 +309,7 @@ async fn ok(#[case] seed: Seed) {
let (alice_sk, alice_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let alice_destination = Destination::Address(PublicKeyHash::from(&alice_pk));
let alice_destination = Destination::PublicKeyHash(PublicKeyHash::from(&alice_pk));
let alice_address =
Address::<Destination>::new(&chain_config, &alice_destination).unwrap();
let mut alice_balance = Amount::from_atoms(1_000_000);
Expand All @@ -318,7 +318,7 @@ async fn ok(#[case] seed: Seed) {
let (_bob_sk, bob_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let bob_destination = Destination::Address(PublicKeyHash::from(&bob_pk));
let bob_destination = Destination::PublicKeyHash(PublicKeyHash::from(&bob_pk));
let bob_address =
Address::<Destination>::new(&chain_config, &bob_destination).unwrap();
let mut bob_balance = Amount::ZERO;
Expand Down
10 changes: 5 additions & 5 deletions api-server/stack-test-suite/tests/v1/address_available_utxos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn address_not_found(#[case] seed: Seed) {
let chain_config = create_unit_test_config();

let (_, public_key) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let destination = Destination::Address(PublicKeyHash::from(&public_key));
let destination = Destination::PublicKeyHash(PublicKeyHash::from(&public_key));
let address = Address::<Destination>::new(&chain_config, &destination).unwrap();

let (task, response) = spawn_webserver(&format!(
Expand Down Expand Up @@ -90,7 +90,7 @@ async fn multiple_utxos_to_single_address(#[case] seed: Seed) {
let (alice_sk, alice_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let alice_destination = Destination::Address(PublicKeyHash::from(&alice_pk));
let alice_destination = Destination::PublicKeyHash(PublicKeyHash::from(&alice_pk));
let alice_address =
Address::<Destination>::new(&chain_config, &alice_destination).unwrap();
let mut alice_balance = Amount::from_atoms(1_000_000);
Expand All @@ -99,7 +99,7 @@ async fn multiple_utxos_to_single_address(#[case] seed: Seed) {
let (_bob_sk, bob_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let bob_destination = Destination::Address(PublicKeyHash::from(&bob_pk));
let bob_destination = Destination::PublicKeyHash(PublicKeyHash::from(&bob_pk));
let bob_address =
Address::<Destination>::new(&chain_config, &bob_destination).unwrap();
let mut bob_utxos = BTreeMap::new();
Expand Down Expand Up @@ -336,7 +336,7 @@ async fn ok(#[case] seed: Seed) {
let (alice_sk, alice_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let alice_destination = Destination::Address(PublicKeyHash::from(&alice_pk));
let alice_destination = Destination::PublicKeyHash(PublicKeyHash::from(&alice_pk));
let alice_address =
Address::<Destination>::new(&chain_config, &alice_destination).unwrap();
let mut alice_balance = Amount::from_atoms(1_000_000);
Expand All @@ -345,7 +345,7 @@ async fn ok(#[case] seed: Seed) {
let (_bob_sk, bob_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let bob_destination = Destination::Address(PublicKeyHash::from(&bob_pk));
let bob_destination = Destination::PublicKeyHash(PublicKeyHash::from(&bob_pk));
let bob_address =
Address::<Destination>::new(&chain_config, &bob_destination).unwrap();
let mut bob_balance = Amount::ZERO;
Expand Down
6 changes: 3 additions & 3 deletions api-server/stack-test-suite/tests/v1/address_delegations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async fn address_not_found(#[case] seed: Seed) {
let chain_config = create_unit_test_config();

let (_, public_key) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let destination = Destination::Address(PublicKeyHash::from(&public_key));
let destination = Destination::PublicKeyHash(PublicKeyHash::from(&public_key));
let address = Address::<Destination>::new(&chain_config, &destination).unwrap();

let (task, response) =
Expand Down Expand Up @@ -93,14 +93,14 @@ async fn ok(#[case] seed: Seed) {
let (_alice_sk, alice_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let alice_destination = Destination::Address(PublicKeyHash::from(&alice_pk));
let alice_destination = Destination::PublicKeyHash(PublicKeyHash::from(&alice_pk));
let alice_address =
Address::<Destination>::new(&chain_config, &alice_destination).unwrap();

let (_bob_sk, bob_pk) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let bob_destination = Destination::Address(PublicKeyHash::from(&bob_pk));
let bob_destination = Destination::PublicKeyHash(PublicKeyHash::from(&bob_pk));
let bob_address =
Address::<Destination>::new(&chain_config, &bob_destination).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion api-server/stack-test-suite/tests/v1/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn prepare_stake_pool(
amount_to_stake,
Destination::PublicKey(pk),
vrf_pk,
Destination::Address(PublicKeyHash::from_low_u64_ne(rng.gen::<u64>())),
Destination::PublicKeyHash(PublicKeyHash::from_low_u64_ne(rng.gen::<u64>())),
PerThousand::new(margin_ratio_per_thousand).unwrap(),
Amount::ZERO,
);
Expand Down
2 changes: 1 addition & 1 deletion api-server/stack-test-suite/tests/v1/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn ok(#[case] seed: Seed) {

let (_, alice_pk) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let alice_destination = Destination::Address(PublicKeyHash::from(&alice_pk));
let alice_destination = Destination::PublicKeyHash(PublicKeyHash::from(&alice_pk));

let nft = NftIssuanceV0 {
metadata: common::chain::tokens::Metadata {
Expand Down
2 changes: 1 addition & 1 deletion api-server/stack-test-suite/tests/v1/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async fn ok(#[case] seed: Seed) {

let (_, alice_pk) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let alice_destination = Destination::Address(PublicKeyHash::from(&alice_pk));
let alice_destination = Destination::PublicKeyHash(PublicKeyHash::from(&alice_pk));

let token_issuance = TokenIssuanceV1 {
token_ticker: "XXXX".as_bytes().to_vec(),
Expand Down
4 changes: 2 additions & 2 deletions api-server/storage-test-suite/src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ where

let (_bob_sk, bob_pk) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let bob_destination = Destination::Address(PublicKeyHash::from(&bob_pk));
let bob_destination = Destination::PublicKeyHash(PublicKeyHash::from(&bob_pk));
let bob_address = Address::<Destination>::new(&chain_config, &bob_destination).unwrap();

let tx = db_tx.get_address_available_utxos(bob_address.get()).await.unwrap();
Expand Down Expand Up @@ -850,7 +850,7 @@ where

let (_, pk) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);

let random_destination = Destination::Address(PublicKeyHash::from(&pk));
let random_destination = Destination::PublicKeyHash(PublicKeyHash::from(&pk));

let token_data = FungibleTokenData {
token_ticker: "XXXX".as_bytes().to_vec(),
Expand Down
2 changes: 1 addition & 1 deletion common/src/address/hexified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod tests {
2 => {
let (_private_key, public_key) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
Destination::Address(PublicKeyHash::from(&public_key))
Destination::PublicKeyHash(PublicKeyHash::from(&public_key))
}
3 => Destination::ScriptHash(crate::primitives::Id::new(H256::random_using(
&mut rng,
Expand Down
2 changes: 1 addition & 1 deletion common/src/address/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ mod tests {
let cfg = create_mainnet();
let (_priv_key, pub_key) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let public_key_hash = PublicKeyHash::from(&pub_key);
let public_key_hash_dest = Destination::Address(public_key_hash);
let public_key_hash_dest = Destination::PublicKeyHash(public_key_hash);
let address = Address::<Destination>::new(&cfg, &public_key_hash_dest)
.expect("Address from pubkeyhash failed");
let public_key_hash_restored_dest = address
Expand Down
8 changes: 4 additions & 4 deletions common/src/chain/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,28 @@ fn address_prefix(chain_type: ChainType, destination: &Destination) -> &'static
match chain_type {
ChainType::Mainnet => match destination {
Destination::AnyoneCanSpend => "mxanyonecanspend",
Destination::Address(_) => "mtc",
Destination::PublicKeyHash(_) => "mtc",
Destination::PublicKey(_) => "mptc",
Destination::ScriptHash(_) => "mstc",
Destination::ClassicMultisig(_) => "mmtc",
},
ChainType::Testnet => match destination {
Destination::AnyoneCanSpend => "txanyonecanspend",
Destination::Address(_) => "tmt",
Destination::PublicKeyHash(_) => "tmt",
Destination::PublicKey(_) => "tpmt",
Destination::ScriptHash(_) => "tstc",
Destination::ClassicMultisig(_) => "tmtc",
},
ChainType::Regtest => match destination {
Destination::AnyoneCanSpend => "rxanyonecanspend",
Destination::Address(_) => "rmt",
Destination::PublicKeyHash(_) => "rmt",
Destination::PublicKey(_) => "rpmt",
Destination::ScriptHash(_) => "rstc",
Destination::ClassicMultisig(_) => "rmtc",
},
ChainType::Signet => match destination {
Destination::AnyoneCanSpend => "sxanyonecanspend",
Destination::Address(_) => "smt",
Destination::PublicKeyHash(_) => "smt",
Destination::PublicKey(_) => "spmt",
Destination::ScriptHash(_) => "sstc",
Destination::ClassicMultisig(_) => "smtc",
Expand Down
2 changes: 1 addition & 1 deletion common/src/chain/transaction/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub enum Destination {
#[codec(index = 0)]
AnyoneCanSpend, // zero verification; used primarily for testing. Never use this for real money
#[codec(index = 1)]
Address(PublicKeyHash),
PublicKeyHash(PublicKeyHash),
#[codec(index = 2)]
PublicKey(crypto::key::PublicKey),
#[codec(index = 3)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ mod test {

let (private_key, public_key) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let destination = Destination::Address(PublicKeyHash::from(&public_key));
let destination = Destination::PublicKeyHash(PublicKeyHash::from(&public_key));

let (inputs_utxos, _priv_keys) = generate_inputs_utxos(&mut rng, INPUTS);
let inputs_utxos_refs = inputs_utxos.iter().map(|utxo| utxo.as_ref()).collect::<Vec<_>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod test {
let (private_key, public_key) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let pubkey_hash = PublicKeyHash::from(&public_key);
let destination = Destination::Address(pubkey_hash);
let destination = Destination::PublicKeyHash(pubkey_hash);

let (inputs_utxos, _priv_keys) = generate_inputs_utxos(&mut rng, 1);
let inputs_utxos_refs = inputs_utxos.iter().map(|utxo| utxo.as_ref()).collect::<Vec<_>>();
Expand Down Expand Up @@ -167,7 +167,7 @@ mod test {
let (private_key, public_key) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let pubkey_hash = PublicKeyHash::from(&public_key);
let destination = Destination::Address(pubkey_hash);
let destination = Destination::PublicKeyHash(pubkey_hash);

let (inputs_utxos, _priv_keys) = generate_inputs_utxos(&mut rng, INPUTS);
let inputs_utxos_refs = inputs_utxos.iter().map(|utxo| utxo.as_ref()).collect::<Vec<_>>();
Expand Down Expand Up @@ -210,7 +210,7 @@ mod test {
let (private_key, public_key) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let pubkey_hash = PublicKeyHash::from(&public_key);
let destination = Destination::Address(pubkey_hash);
let destination = Destination::PublicKeyHash(pubkey_hash);

let (inputs_utxos, _priv_keys) = generate_inputs_utxos(&mut rng, INPUTS);
let inputs_utxos_refs = inputs_utxos.iter().map(|utxo| utxo.as_ref()).collect::<Vec<_>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl StandardInputSignature {
sighash: &H256,
) -> Result<(), TransactionSigError> {
match outpoint_destination {
Destination::Address(addr) => {
Destination::PublicKeyHash(addr) => {
let sig_components = AuthorizedPublicKeyHashSpend::from_data(&self.raw_signature)?;
verify_address_spending(addr, &sig_components, sighash)?
}
Expand Down Expand Up @@ -108,7 +108,7 @@ impl StandardInputSignature {
) -> Result<Self, TransactionSigError> {
let sighash = signature_hash(sighash_type, tx, inputs_utxos, input_num)?;
let serialized_sig = match outpoint_destination {
Destination::Address(ref addr) => {
Destination::PublicKeyHash(ref addr) => {
let sig = sign_address_spending(private_key, addr, &sighash)?;
sig.encode()
}
Expand Down Expand Up @@ -233,7 +233,7 @@ mod test {

let (private_key, _) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let (_, public_key) = PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let destination = Destination::Address(PublicKeyHash::from(&public_key));
let destination = Destination::PublicKeyHash(PublicKeyHash::from(&public_key));

let (inputs_utxos, _priv_keys) = generate_inputs_utxos(&mut rng, 1);
let inputs_utxos_refs = inputs_utxos.iter().map(|utxo| utxo.as_ref()).collect::<Vec<_>>();
Expand Down Expand Up @@ -298,7 +298,7 @@ mod test {
let (private_key, public_key) =
PrivateKey::new_from_rng(&mut rng, KeyKind::Secp256k1Schnorr);
let outpoints = [
Destination::Address(PublicKeyHash::from(&public_key)),
Destination::PublicKeyHash(PublicKeyHash::from(&public_key)),
Destination::PublicKey(public_key),
];

Expand Down
2 changes: 1 addition & 1 deletion common/src/chain/transaction/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub fn verify_signature<T: Transactable>(

match input_witness {
InputWitness::NoSignature(_) => match outpoint_destination {
Destination::Address(_)
Destination::PublicKeyHash(_)
| Destination::PublicKey(_)
| Destination::ScriptHash(_)
| Destination::ClassicMultisig(_) => {
Expand Down
Loading

0 comments on commit 48eba63

Please sign in to comment.