grin-wallet master now building against grin master (#402)

This commit is contained in:
Antioch Peverell
2020-05-11 10:27:47 +01:00
committed by GitHub
parent dceeda93be
commit 19da1e4aec
10 changed files with 75 additions and 76 deletions
+7 -6
View File
@@ -36,7 +36,7 @@ use crate::libwallet::{
};
use crate::util::secp::constants::SECRET_KEY_SIZE;
use crate::util::secp::key::SecretKey;
use crate::util::{self, secp};
use crate::util::{self, secp, ToHex};
use rand::rngs::mock::StepRng;
use rand::thread_rng;
@@ -263,12 +263,13 @@ where
/*if self.config.no_commit_cache == Some(true) {
Ok(None)
} else {*/
Ok(Some(util::to_hex(
Ok(Some(
self.keychain(keychain_mask)?
.commit(amount, &id, SwitchCommitmentType::Regular)?
.0
.to_vec(), // TODO: proper support for different switch commitment schemes
)))
.to_vec()
.to_hex(), // TODO: proper support for different switch commitment schemes
))
/*}*/
}
@@ -362,7 +363,7 @@ where
.join(filename);
let path_buf = Path::new(&path).to_path_buf();
let mut stored_tx = File::create(path_buf)?;
let tx_hex = util::to_hex(ser::ser_vec(tx, ser::ProtocolVersion(1)).unwrap());
let tx_hex = ser::ser_vec(tx, ser::ProtocolVersion(1)).unwrap().to_hex();
stored_tx.write_all(&tx_hex.as_bytes())?;
stored_tx.sync_all()?;
Ok(())
@@ -382,7 +383,7 @@ where
tx_f.read_to_string(&mut content)?;
let tx_bin = util::from_hex(&content).unwrap();
Ok(Some(
ser::deserialize::<Transaction>(&mut &tx_bin[..], ser::ProtocolVersion(1)).unwrap(),
ser::deserialize(&mut &tx_bin[..], ser::ProtocolVersion(1)).unwrap(),
))
}
+5 -5
View File
@@ -26,7 +26,7 @@ use ring::aead;
use ring::pbkdf2;
use crate::keychain::{mnemonic, Keychain};
use crate::util;
use crate::util::{self, ToHex};
use crate::{Error, ErrorKind};
use failure::ResultExt;
@@ -55,7 +55,7 @@ impl WalletSeed {
}
pub fn _to_hex(&self) -> String {
util::to_hex(self.0.to_vec())
self.0.to_vec().to_hex()
}
pub fn to_mnemonic(&self) -> Result<String, Error> {
@@ -266,9 +266,9 @@ impl EncryptedWalletSeed {
}
Ok(EncryptedWalletSeed {
encrypted_seed: util::to_hex(enc_bytes.to_vec()),
salt: util::to_hex(salt.to_vec()),
nonce: util::to_hex(nonce.to_vec()),
encrypted_seed: enc_bytes.to_hex(),
salt: salt.to_hex(),
nonce: nonce.to_hex(),
})
}
+4 -4
View File
@@ -27,7 +27,7 @@ use tokio::runtime::Builder;
use crate::client_utils::Client;
use crate::libwallet;
use crate::util::secp::pedersen;
use crate::util::{self, to_hex};
use crate::util::ToHex;
use super::resp_types::*;
use crate::client_utils::json_rpc::*;
@@ -154,7 +154,7 @@ impl NodeClient for HTTPNodeClient {
max_height: Option<u64>,
) -> Result<Option<(TxKernel, u64, u64)>, libwallet::Error> {
let method = "get_kernel";
let params = json!([to_hex(excess.0.to_vec()), min_height, max_height]);
let params = json!([excess.0.as_ref().to_hex(), min_height, max_height]);
// have to handle this manually since the error needs to be parsed
let url = format!("{}{}", self.node_url(), ENDPOINT);
let client = Client::new();
@@ -198,7 +198,7 @@ impl NodeClient for HTTPNodeClient {
// build vec of commits for inclusion in query
let query_params: Vec<String> = wallet_outputs
.iter()
.map(|commit| format!("{}", util::to_hex(commit.as_ref().to_vec())))
.map(|commit| format!("{}", commit.as_ref().to_hex()))
.collect();
// going to leave this here even though we're moving
@@ -297,7 +297,7 @@ impl NodeClient for HTTPNodeClient {
};
api_outputs.insert(
out.commit,
(util::to_hex(out.commit.0.to_vec()), height, out.mmr_index),
(out.commit.as_ref().to_hex(), height, out.mmr_index),
);
}
Ok(api_outputs)
+5 -5
View File
@@ -32,7 +32,7 @@ use crate::util;
use crate::util::secp::key::SecretKey;
use crate::util::secp::pedersen;
use crate::util::secp::pedersen::Commitment;
use crate::util::{Mutex, RwLock};
use crate::util::{Mutex, RwLock, ToHex};
use failure::ResultExt;
use serde_json;
use std::collections::HashMap;
@@ -253,7 +253,7 @@ where
m: WalletProxyMessage,
) -> Result<WalletProxyMessage, libwallet::Error> {
let height = self.chain.head().unwrap().height;
let hash = util::to_hex(self.chain.head().unwrap().last_block_h.to_vec());
let hash = self.chain.head().unwrap().last_block_h.to_hex();
Ok(WalletProxyMessage {
sender_id: "node".to_owned(),
@@ -489,7 +489,7 @@ impl NodeClient for LocalWalletClient {
) -> Result<HashMap<pedersen::Commitment, (String, u64, u64)>, libwallet::Error> {
let query_params: Vec<String> = wallet_outputs
.iter()
.map(|commit| util::to_hex(commit.as_ref().to_vec()))
.map(|commit| commit.as_ref().to_hex())
.collect();
let query_str = query_params.join(",");
let m = WalletProxyMessage {
@@ -511,7 +511,7 @@ impl NodeClient for LocalWalletClient {
for out in outputs {
api_outputs.insert(
out.commit.commit(),
(util::to_hex(out.commit.to_vec()), out.height, out.mmr_index),
(out.commit.to_hex(), out.height, out.mmr_index),
);
}
Ok(api_outputs)
@@ -523,7 +523,7 @@ impl NodeClient for LocalWalletClient {
min_height: Option<u64>,
max_height: Option<u64>,
) -> Result<Option<(TxKernel, u64, u64)>, libwallet::Error> {
let mut query = format!("{},", util::to_hex(excess.0.to_vec()));
let mut query = format!("{},", excess.0.as_ref().to_hex());
if let Some(h) = min_height {
query += &format!("{},", h);
} else {