mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-24 02:18:32 +02:00
Proof of Payment Command Line (#260)
* refactor address generation code into libwallet, bool to flag whether to include proof, add sender address in init_send_tx * rustfmt * require payment proof addr as part of init_tx * rustfmt * store payment proof on sender transaction side * rustfmt * change sig to ed25519 sig * rustfmt * add message creation and signature * rustfmt * add payment proof verification function * rustfmt * validate proof on sender side, store proof * rustfmt * fix json tests * fixes and updates to tests * added API functions for converting and retrieving proof addresses * rustfmt * add payment proof to init_send_tx example * rustfmt * incorrect comment * add commands for requesting payment proofs * rustfmt * wire up payment proofs into command line * rustfmt * add address command * rustfmt * added tor sending from owner api * rustfmt
This commit is contained in:
+19
-2
@@ -73,6 +73,9 @@ where
|
||||
/// Holds all update and status messages returned by the
|
||||
/// updater process
|
||||
updater_messages: Arc<Mutex<Vec<StatusMessage>>>,
|
||||
/// Optional TOR configuration, holding address of sender and
|
||||
/// data directory
|
||||
tor_config: Mutex<Option<TorConfig>>,
|
||||
}
|
||||
|
||||
impl<L, C, K> Owner<L, C, K>
|
||||
@@ -176,9 +179,23 @@ where
|
||||
updater_running,
|
||||
status_tx: Mutex::new(Some(tx)),
|
||||
updater_messages,
|
||||
tor_config: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the TOR configuration for this instance of the OwnerAPI, used during
|
||||
/// `init_send_tx` when send args are present and a TOR address is specified
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `tor_config` - The optional [TorConfig](#) to use
|
||||
/// # Returns
|
||||
/// * Nothing
|
||||
|
||||
pub fn set_tor_config(&self, tor_config: Option<TorConfig>) {
|
||||
let mut lock = self.tor_config.lock();
|
||||
*lock = tor_config;
|
||||
}
|
||||
|
||||
/// Returns a list of accounts stored in the wallet (i.e. mappings between
|
||||
/// user-specified labels and BIP32 derivation paths.
|
||||
/// # Arguments
|
||||
@@ -636,8 +653,8 @@ where
|
||||
.into());
|
||||
}
|
||||
};
|
||||
//TODO: no TOR just now via this method, to keep compatibility for now
|
||||
let comm_adapter = create_sender(&sa.method, &sa.dest, None)
|
||||
let tor_config_lock = self.tor_config.lock();
|
||||
let comm_adapter = create_sender(&sa.method, &sa.dest, tor_config_lock.clone())
|
||||
.map_err(|e| ErrorKind::GenericError(format!("{}", e)))?;
|
||||
slate = comm_adapter.send_tx(&slate)?;
|
||||
self.tx_lock_outputs(keychain_mask, &slate, 0)?;
|
||||
|
||||
@@ -1849,6 +1849,39 @@ pub trait OwnerRpcS {
|
||||
*/
|
||||
|
||||
fn proof_address_from_onion_v3(&self, address_v3: String) -> Result<PubAddress, ErrorKind>;
|
||||
|
||||
/**
|
||||
Networked version of [Owner::set_tor_config](struct.Owner.html#method.set_tor_config).
|
||||
```
|
||||
# grin_wallet_api::doctest_helper_json_rpc_owner_assert_response!(
|
||||
# r#"
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "set_tor_config",
|
||||
"params": {
|
||||
"tor_config": {
|
||||
"use_tor_listener": true,
|
||||
"socks_proxy_addr": "127.0.0.1:59050",
|
||||
"send_config_dir": "."
|
||||
}
|
||||
},
|
||||
"id": 1
|
||||
}
|
||||
# "#
|
||||
# ,
|
||||
# r#"
|
||||
{
|
||||
"id": 1,
|
||||
"jsonrpc": "2.0",
|
||||
"result": {
|
||||
"Ok": null
|
||||
}
|
||||
}
|
||||
# "#
|
||||
# , true, 0, false, false, false);
|
||||
```
|
||||
*/
|
||||
fn set_tor_config(&self, tor_config: Option<TorConfig>) -> Result<(), ErrorKind>;
|
||||
}
|
||||
|
||||
impl<L, C, K> OwnerRpcS for Owner<L, C, K>
|
||||
@@ -2173,4 +2206,9 @@ where
|
||||
Owner::proof_address_from_onion_v3(self, &address_v3).map_err(|e| e.kind())?;
|
||||
Ok(PubAddress { address })
|
||||
}
|
||||
|
||||
fn set_tor_config(&self, tor_config: Option<TorConfig>) -> Result<(), ErrorKind> {
|
||||
Owner::set_tor_config(self, tor_config);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user