Rename Network::address to Network::external_address

Improves clarity since we now have 4 addresses.
This commit is contained in:
Luke Parker 2023-11-09 14:31:40 -05:00
parent 42e8f2c8d8
commit 52a0c56016
No known key found for this signature in database
7 changed files with 13 additions and 13 deletions

View file

@ -538,23 +538,23 @@ impl Network for Bitcoin {
scanner(keys.group_key());
}
fn address(key: ProjectivePoint) -> Address {
fn external_address(key: ProjectivePoint) -> Address {
Address(BAddress::<NetworkChecked>::new(BNetwork::Bitcoin, address_payload(key).unwrap()))
}
fn branch_address(key: ProjectivePoint) -> Address {
let (_, offsets, _) = scanner(key);
Self::address(key + (ProjectivePoint::GENERATOR * offsets[&OutputType::Branch]))
Self::external_address(key + (ProjectivePoint::GENERATOR * offsets[&OutputType::Branch]))
}
fn change_address(key: ProjectivePoint) -> Address {
let (_, offsets, _) = scanner(key);
Self::address(key + (ProjectivePoint::GENERATOR * offsets[&OutputType::Change]))
Self::external_address(key + (ProjectivePoint::GENERATOR * offsets[&OutputType::Change]))
}
fn forward_address(key: ProjectivePoint) -> Address {
let (_, offsets, _) = scanner(key);
Self::address(key + (ProjectivePoint::GENERATOR * offsets[&OutputType::Forwarded]))
Self::external_address(key + (ProjectivePoint::GENERATOR * offsets[&OutputType::Forwarded]))
}
async fn get_latest_block_number(&self) -> Result<usize, NetworkError> {

View file

@ -293,7 +293,7 @@ pub trait Network: 'static + Send + Sync + Clone + PartialEq + Eq + Debug {
fn tweak_keys(key: &mut ThresholdKeys<Self::Curve>);
/// Address for the given group key to receive external coins to.
fn address(key: <Self::Curve as Ciphersuite>::G) -> Self::Address;
fn external_address(key: <Self::Curve as Ciphersuite>::G) -> Self::Address;
/// Address for the given group key to use for scheduled branches.
fn branch_address(key: <Self::Curve as Ciphersuite>::G) -> Self::Address;
/// Address for the given group key to use for change.

View file

@ -475,7 +475,7 @@ impl Network for Monero {
// Monero doesn't require/benefit from tweaking
fn tweak_keys(_: &mut ThresholdKeys<Self::Curve>) {}
fn address(key: EdwardsPoint) -> Address {
fn external_address(key: EdwardsPoint) -> Address {
Self::address_internal(key, EXTERNAL_SUBADDRESS)
}

View file

@ -99,7 +99,7 @@ pub async fn test_addresses<N: Network>(network: N) {
// Receive funds to the various addresses and make sure they're properly identified
let mut received_outputs = vec![];
for (kind, address) in [
(OutputType::External, N::address(key)),
(OutputType::External, N::external_address(key)),
(OutputType::Branch, N::branch_address(key)),
(OutputType::Change, N::change_address(key)),
(OutputType::Forwarded, N::forward_address(key)),

View file

@ -49,7 +49,7 @@ pub async fn test_scanner<N: Network>(network: N) {
let scanner = new_scanner().await;
// Receive funds
let block = network.test_send(N::address(keys.group_key())).await;
let block = network.test_send(N::external_address(keys.group_key())).await;
let block_id = block.id();
// Verify the Scanner picked them up

View file

@ -155,7 +155,7 @@ pub async fn test_signer<N: Network>(network: N) {
}
let key = keys[&Participant::new(1).unwrap()].group_key();
let outputs = network.get_outputs(&network.test_send(N::address(key)).await, key).await;
let outputs = network.get_outputs(&network.test_send(N::external_address(key)).await, key).await;
let sync_block = network.get_latest_block_number().await.unwrap() - N::CONFIRMATIONS;
let amount = 2 * N::DUST;
@ -169,7 +169,7 @@ pub async fn test_signer<N: Network>(network: N) {
key,
inputs: outputs.clone(),
payments: vec![Payment {
address: N::address(key),
address: N::external_address(key),
data: None,
balance: Balance {
coin: match N::NETWORK {

View file

@ -44,7 +44,7 @@ pub async fn test_wallet<N: Network>(network: N) {
network.mine_block().await;
}
let block = network.test_send(N::address(key)).await;
let block = network.test_send(N::external_address(key)).await;
let block_id = block.id();
match timeout(Duration::from_secs(30), scanner.events.recv()).await.unwrap().unwrap() {
@ -81,7 +81,7 @@ pub async fn test_wallet<N: Network>(network: N) {
&mut txn,
outputs.clone(),
vec![Payment {
address: N::address(key),
address: N::external_address(key),
data: None,
balance: Balance {
coin: match N::NETWORK {
@ -103,7 +103,7 @@ pub async fn test_wallet<N: Network>(network: N) {
key,
inputs: outputs.clone(),
payments: vec![Payment {
address: N::address(key),
address: N::external_address(key),
data: None,
balance: Balance {
coin: match N::NETWORK {