mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-25 18:08:33 +01:00
Onion V3 address consistency (#309)
* initial addition of ov3 * move libwallet address functions into OnionV3Address type * incorporate OnionV3 type where possible * factor out manual dalek pubkey manipulations * corrections due to test failures * change json-rpc example to use ov3 for payment proof recipient address
This commit is contained in:
+12
-29
@@ -22,12 +22,12 @@ use crate::impls::{create_sender, KeybaseAllChannels, SlateGetter as _, SlateRec
|
||||
use crate::impls::{PathToSlate, SlatePutter};
|
||||
use crate::keychain;
|
||||
use crate::libwallet::{
|
||||
self, address, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, WalletInst,
|
||||
WalletLCProvider,
|
||||
self, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, WalletInst, WalletLCProvider,
|
||||
};
|
||||
use crate::util::secp::key::SecretKey;
|
||||
use crate::util::{to_hex, Mutex, ZeroingString};
|
||||
use crate::util::{Mutex, ZeroingString};
|
||||
use crate::{controller, display};
|
||||
use grin_wallet_util::OnionV3Address;
|
||||
use serde_json as json;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
@@ -253,7 +253,7 @@ pub struct SendArgs {
|
||||
pub fluff: bool,
|
||||
pub max_outputs: usize,
|
||||
pub target_slate_version: Option<u16>,
|
||||
pub payment_proof_address: Option<String>,
|
||||
pub payment_proof_address: Option<OnionV3Address>,
|
||||
pub ttl_blocks: Option<u64>,
|
||||
}
|
||||
|
||||
@@ -290,10 +290,6 @@ where
|
||||
.collect();
|
||||
display::estimate(args.amount, strategies, dark_scheme);
|
||||
} else {
|
||||
let payment_proof_recipient_address = match args.payment_proof_address {
|
||||
Some(ref p) => Some(address::ed25519_parse_pubkey(p)?),
|
||||
None => None,
|
||||
};
|
||||
let init_args = InitTxArgs {
|
||||
src_acct_name: None,
|
||||
amount: args.amount,
|
||||
@@ -303,7 +299,7 @@ where
|
||||
selection_strategy_is_use_all: args.selection_strategy == "all",
|
||||
message: args.message.clone(),
|
||||
target_slate_version: args.target_slate_version,
|
||||
payment_proof_recipient_address,
|
||||
payment_proof_recipient_address: args.payment_proof_address.clone(),
|
||||
ttl_blocks: args.ttl_blocks,
|
||||
send_args: None,
|
||||
..Default::default()
|
||||
@@ -897,26 +893,13 @@ where
|
||||
controller::owner_single_use(wallet.clone(), keychain_mask, |api, m| {
|
||||
// Just address at derivation index 0 for now
|
||||
let pub_key = api.get_public_proof_address(m, 0)?;
|
||||
let result = address::onion_v3_from_pubkey(&pub_key);
|
||||
match result {
|
||||
Ok(a) => {
|
||||
println!();
|
||||
println!("Public Proof Address for account - {}", g_args.account);
|
||||
println!("-------------------------------------");
|
||||
println!("{}", to_hex(pub_key.as_bytes().to_vec()));
|
||||
println!();
|
||||
println!("TOR Onion V3 Address for account - {}", g_args.account);
|
||||
println!("-------------------------------------");
|
||||
println!("{}", a);
|
||||
println!();
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Address retrieval failed: {}", e);
|
||||
error!("Backtrace: {}", e.backtrace().unwrap());
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
let addr = OnionV3Address::from_bytes(pub_key.to_bytes());
|
||||
println!();
|
||||
println!("Address for account - {}", g_args.account);
|
||||
println!("-------------------------------------");
|
||||
println!("{}", addr);
|
||||
println!();
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use crate::util::{from_hex, static_secp_instance, to_base64, Mutex};
|
||||
use failure::ResultExt;
|
||||
use futures::future::{err, ok};
|
||||
use futures::{Future, Stream};
|
||||
use grin_wallet_util::OnionV3Address;
|
||||
use hyper::header::HeaderValue;
|
||||
use hyper::{Body, Request, Response, StatusCode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -98,7 +99,7 @@ where
|
||||
let tor_dir = format!("{}/tor/listener", lc.get_top_level_directory()?);
|
||||
let sec_key = address::address_from_derivation_path(&k, &parent_key_id, 0)
|
||||
.map_err(|e| ErrorKind::TorConfig(format!("{:?}", e).into()))?;
|
||||
let onion_address = tor_config::onion_address_from_seckey(&sec_key)
|
||||
let onion_address = OnionV3Address::from_private(&sec_key.0)
|
||||
.map_err(|e| ErrorKind::TorConfig(format!("{:?}", e).into()))?;
|
||||
warn!(
|
||||
"Starting TOR Hidden Service for API listener at address {}, binding to {}",
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
use crate::core::core::{self, amount_to_hr_string};
|
||||
use crate::core::global;
|
||||
use crate::libwallet::{
|
||||
address, AcctPathMapping, Error, OutputCommitMapping, OutputStatus, TxLogEntry, WalletInfo,
|
||||
AcctPathMapping, Error, OutputCommitMapping, OutputStatus, TxLogEntry, WalletInfo,
|
||||
};
|
||||
use crate::util;
|
||||
use grin_wallet_util::OnionV3Address;
|
||||
use prettytable;
|
||||
use std::io::prelude::Write;
|
||||
use term;
|
||||
@@ -537,8 +538,6 @@ pub fn payment_proof(tx: &TxLogEntry) -> Result<(), Error> {
|
||||
|
||||
t.fg(term::color::WHITE).unwrap();
|
||||
writeln!(t).unwrap();
|
||||
let receiver_address = util::to_hex(pp.receiver_address.to_bytes().to_vec());
|
||||
let receiver_onion_address = address::onion_v3_from_pubkey(&pp.receiver_address)?;
|
||||
let receiver_signature = match pp.receiver_signature {
|
||||
Some(s) => util::to_hex(s.to_bytes().to_vec()),
|
||||
None => "None".to_owned(),
|
||||
@@ -556,8 +555,6 @@ pub fn payment_proof(tx: &TxLogEntry) -> Result<(), Error> {
|
||||
)
|
||||
};
|
||||
|
||||
let sender_address = util::to_hex(pp.sender_address.to_bytes().to_vec());
|
||||
let sender_onion_address = address::onion_v3_from_pubkey(&pp.sender_address)?;
|
||||
let sender_signature = match pp.sender_signature {
|
||||
Some(s) => util::to_hex(s.to_bytes().to_vec()),
|
||||
None => "None".to_owned(),
|
||||
@@ -567,14 +564,22 @@ pub fn payment_proof(tx: &TxLogEntry) -> Result<(), Error> {
|
||||
None => "None".to_owned(),
|
||||
};
|
||||
|
||||
writeln!(t, "Receiver Address: {}", receiver_address).unwrap();
|
||||
writeln!(t, "Receiver Address (Onion V3): {}", receiver_onion_address).unwrap();
|
||||
writeln!(
|
||||
t,
|
||||
"Receiver Address: {}",
|
||||
OnionV3Address::from_bytes(pp.receiver_address.to_bytes())
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(t, "Receiver Signature: {}", receiver_signature).unwrap();
|
||||
writeln!(t, "Amount: {}", amount).unwrap();
|
||||
writeln!(t, "Kernel Excess: {}", kernel_excess).unwrap();
|
||||
writeln!(t, "Sender Address: {}", sender_address).unwrap();
|
||||
writeln!(
|
||||
t,
|
||||
"Sender Address: {}",
|
||||
OnionV3Address::from_bytes(pp.sender_address.to_bytes())
|
||||
)
|
||||
.unwrap();
|
||||
writeln!(t, "Sender Signature: {}", sender_signature).unwrap();
|
||||
writeln!(t, "Sender Address (Onion V3): {}", sender_onion_address).unwrap();
|
||||
|
||||
t.reset().unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user