Skip to content

Commit a8be757

Browse files
authored
Merge pull request #94 from blacktyger/add-epicbox-domain
[FIX] Improve epicbox address api calls
2 parents b0678b9 + 0450947 commit a8be757

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

api/src/owner.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,17 @@ where
20202020
keychain_mask: Option<&SecretKey>,
20212021
derivation_index: u32,
20222022
) -> Result<EpicboxAddress, Error> {
2023-
owner::get_public_address(self.wallet_inst.clone(), keychain_mask, derivation_index)
2023+
let epicbox_config_lock = self.epicbox_config.lock();
2024+
let epicbox_config = match epicbox_config_lock.clone() {
2025+
None => EpicboxConfig::default(),
2026+
Some(epicbox_config) => epicbox_config,
2027+
};
2028+
owner::get_public_address(
2029+
self.wallet_inst.clone(),
2030+
keychain_mask,
2031+
epicbox_config,
2032+
derivation_index,
2033+
)
20242034
}
20252035

20262036
/// Retrieve the public proof "addresses" associated with the active account at the

controller/src/command.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ pub fn address<L, C, K>(
971971
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K>>>>,
972972
g_args: &GlobalArgs,
973973
keychain_mask: Option<&SecretKey>,
974+
epicbox_config: EpicboxConfig,
974975
) -> Result<(), Error>
975976
where
976977
L: WalletLCProvider<'static, C, K> + 'static,
@@ -981,15 +982,18 @@ where
981982
// Just address at derivation index 0 for now
982983
let pub_key = api.get_public_proof_address(m, 0)?;
983984
let result = address::onion_v3_from_pubkey(&pub_key);
984-
985985
let address = api.get_public_address(m, 0)?;
986986

987987
match result {
988988
Ok(a) => {
989989
println!();
990-
println!("Address for account - {}", g_args.account);
990+
println!("Epicbox address for account - {}", g_args.account);
991991
println!("-------------------------------------");
992-
println!("{}", address.public_key);
992+
println!(
993+
"{}@{}",
994+
address.public_key,
995+
epicbox_config.epicbox_domain.unwrap()
996+
);
993997
println!();
994998
println!("Public Proof Address for account - {}", g_args.account);
995999
println!("-------------------------------------");

libwallet/src/api_impl/owner.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::epic_util::secp::key::SecretKey;
2424
use crate::epic_util::Mutex;
2525

2626
use crate::api_impl::owner_updater::StatusMessage;
27+
use crate::config::EpicboxConfig;
2728
use crate::epic_keychain::{Identifier, Keychain};
2829
use crate::epic_util::secp::key::PublicKey;
2930
use crate::epicbox_address::EpicboxAddress;
@@ -104,6 +105,7 @@ where
104105
pub fn get_public_address<'a, L, C, K>(
105106
wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
106107
keychain_mask: Option<&SecretKey>,
108+
epicbox_config: EpicboxConfig,
107109
index: u32,
108110
) -> Result<EpicboxAddress, Error>
109111
where
@@ -116,8 +118,11 @@ where
116118
let k = w.keychain(keychain_mask)?;
117119
let sec_addr_key = address::address_from_derivation_path(&k, &parent_key_id, index)?;
118120
let pub_key = PublicKey::from_secret_key(k.secp(), &sec_addr_key).unwrap();
119-
120-
Ok(EpicboxAddress::new(pub_key, Some("".to_string()), Some(0)))
121+
Ok(EpicboxAddress::new(
122+
pub_key,
123+
Some(epicbox_config.epicbox_domain.unwrap()),
124+
Some(epicbox_config.epicbox_port.unwrap()),
125+
))
121126
}
122127

123128
/// retrieve outputs

src/bin/epic-wallet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ subcommands:
381381
- recover:
382382
about: Displays a recovery phrase for the wallet. (use `init -r` to perform recovery)
383383
- address:
384-
about: Display the wallet's payment proof address
384+
about: Display the wallet's Epicbox public address, the payment proof address and the TOR address
385385
- scan:
386386
about: Checks a wallet's outputs against a live node, repairing and restoring missing outputs if required
387387
args:

src/cmd/wallet_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ where
10891089
let a = arg_parse!(parse_verify_proof_args(&args));
10901090
command::proof_verify(wallet, km, a)
10911091
}
1092-
("address", Some(_)) => command::address(wallet, &global_wallet_args, km),
1092+
("address", Some(_)) => command::address(wallet, &global_wallet_args, km, epicbox_config),
10931093
("scan", Some(args)) => {
10941094
let a = arg_parse!(parse_check_args(&args));
10951095
command::scan(wallet, km, a)

0 commit comments

Comments
 (0)