mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 15:21:39 +02: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:
+5
-2
@@ -26,13 +26,15 @@ use crate::keychain::{Identifier, Keychain};
|
||||
use crate::libwallet::api_impl::owner_updater::{start_updater_log_thread, StatusMessage};
|
||||
use crate::libwallet::api_impl::{owner, owner_updater};
|
||||
use crate::libwallet::{
|
||||
address, AcctPathMapping, Error, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
|
||||
AcctPathMapping, Error, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient,
|
||||
NodeHeightResult, OutputCommitMapping, PaymentProof, Slate, TxLogEntry, WalletInfo, WalletInst,
|
||||
WalletLCProvider,
|
||||
};
|
||||
use crate::util::logger::LoggingConfig;
|
||||
use crate::util::secp::key::SecretKey;
|
||||
use crate::util::{from_hex, static_secp_instance, Mutex, ZeroingString};
|
||||
use grin_wallet_util::OnionV3Address;
|
||||
use std::convert::TryFrom;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::sync::Arc;
|
||||
@@ -2010,7 +2012,8 @@ where
|
||||
/// ```
|
||||
|
||||
pub fn proof_address_from_onion_v3(&self, address_v3: &str) -> Result<DalekPublicKey, Error> {
|
||||
address::pubkey_from_onion_v3(address_v3)
|
||||
let addr = OnionV3Address::try_from(address_v3)?;
|
||||
Ok(addr.to_ed25519()?)
|
||||
}
|
||||
|
||||
/// Returns a single, exportable [PaymentProof](../grin_wallet_libwallet/api_impl/types/struct.PaymentProof.html)
|
||||
|
||||
+5
-10
@@ -23,9 +23,11 @@ use crate::libwallet::{
|
||||
OutputCommitMapping, Slate, SlateVersion, TxLogEntry, VersionedSlate, WalletInfo,
|
||||
WalletLCProvider,
|
||||
};
|
||||
use crate::util::{from_hex, Mutex};
|
||||
use crate::util::Mutex;
|
||||
use crate::{Owner, OwnerRpcS};
|
||||
use easy_jsonrpc_mw;
|
||||
use grin_wallet_util::OnionV3Address;
|
||||
use std::convert::TryFrom;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Public definition used to generate Owner jsonrpc api.
|
||||
@@ -1380,8 +1382,6 @@ pub fn run_doctest_owner(
|
||||
use grin_wallet_libwallet::{api_impl, WalletInst};
|
||||
use grin_wallet_util::grin_keychain::ExtKeychain;
|
||||
|
||||
use ed25519_dalek::PublicKey as DalekPublicKey;
|
||||
|
||||
use crate::core::global;
|
||||
use crate::core::global::ChainTypes;
|
||||
use grin_wallet_util::grin_util as util;
|
||||
@@ -1510,13 +1510,8 @@ pub fn run_doctest_owner(
|
||||
let w = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
|
||||
let proof_address = match payment_proof {
|
||||
true => {
|
||||
let bytes = from_hex(
|
||||
"783f6528669742a990e0faf0a5fca5d5b3330e37bbb9cd5c628696d03ce4e810".to_string(),
|
||||
)
|
||||
.unwrap();
|
||||
let mut b = [0u8; 32];
|
||||
b.copy_from_slice(&bytes[0..32]);
|
||||
Some(DalekPublicKey::from_bytes(&b).unwrap())
|
||||
let address = "783f6528669742a990e0faf0a5fca5d5b3330e37bbb9cd5c628696d03ce4e810";
|
||||
Some(OnionV3Address::try_from(address).unwrap())
|
||||
}
|
||||
false => None,
|
||||
};
|
||||
|
||||
@@ -376,7 +376,7 @@ pub trait OwnerRpcS {
|
||||
"selection_strategy_is_use_all": true,
|
||||
"message": "my message",
|
||||
"target_slate_version": null,
|
||||
"payment_proof_recipient_address": "d03c09e9c19bb74aa9ea44e0fe5ae237a9bf40bddf0941064a80913a4459c8bb",
|
||||
"payment_proof_recipient_address": "pa7wkkdgs5bkteha7lykl7ff2wztgdrxxo442xdcq2lnaphe5aidd4id",
|
||||
"ttl_blocks": null,
|
||||
"send_args": null
|
||||
}
|
||||
@@ -399,7 +399,7 @@ pub trait OwnerRpcS {
|
||||
"ttl_cutoff_height": null,
|
||||
"num_participants": 2,
|
||||
"payment_proof": {
|
||||
"receiver_address": "d03c09e9c19bb74aa9ea44e0fe5ae237a9bf40bddf0941064a80913a4459c8bb",
|
||||
"receiver_address": "783f6528669742a990e0faf0a5fca5d5b3330e37bbb9cd5c628696d03ce4e810",
|
||||
"receiver_signature": null,
|
||||
"sender_address": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user