diff --git a/wallet/src/client.rs b/wallet/src/client.rs index f7f250fad..78dec7c79 100644 --- a/wallet/src/client.rs +++ b/wallet/src/client.rs @@ -55,11 +55,11 @@ where Ok(res) } -pub fn send_partial_tx(url: &str, partial_tx: &JSONPartialTx) -> Result<(), Error> { +pub fn send_partial_tx(url: &str, partial_tx: &PartialTx) -> Result<(), Error> { single_send_partial_tx(url, partial_tx) } -fn single_send_partial_tx(url: &str, partial_tx: &JSONPartialTx) -> Result<(), Error> { +fn single_send_partial_tx(url: &str, partial_tx: &PartialTx) -> Result<(), Error> { let mut core = reactor::Core::new()?; let client = hyper::Client::new(&core.handle()); diff --git a/wallet/src/receiver.rs b/wallet/src/receiver.rs index 7eb015cbf..2ac3b556f 100644 --- a/wallet/src/receiver.rs +++ b/wallet/src/receiver.rs @@ -52,7 +52,7 @@ pub fn receive_json_tx_str( pub fn receive_json_tx( config: &WalletConfig, keychain: &Keychain, - partial_tx: &JSONPartialTx, + partial_tx: &PartialTx, ) -> Result<(), Error> { let (amount, blinding, tx) = read_partial_tx(keychain, partial_tx)?; let final_tx = receive_transaction(config, keychain, amount, blinding, tx)?; @@ -74,7 +74,7 @@ pub struct WalletReceiver { impl Handler for WalletReceiver { fn handle(&self, req: &mut Request) -> IronResult { - let struct_body = req.get::>(); + let struct_body = req.get::>(); if let Ok(Some(partial_tx)) = struct_body { receive_json_tx(&self.config, &self.keychain, &partial_tx) diff --git a/wallet/src/types.rs b/wallet/src/types.rs index 923a7f145..06fe6a7bc 100644 --- a/wallet/src/types.rs +++ b/wallet/src/types.rs @@ -531,20 +531,19 @@ impl WalletData { /// Helper in serializing the information a receiver requires to build a /// transaction. #[derive(Serialize, Deserialize, Debug, Clone)] -pub struct JSONPartialTx { +pub struct PartialTx { amount: u64, blind_sum: String, tx: String, } -/// Encodes the information for a partial transaction (not yet completed by the -/// receiver) into JSON. +/// Builds a PartialTx from data sent by a sender (not yet completed by the receiver). pub fn build_partial_tx( receive_amount: u64, blind_sum: keychain::BlindingFactor, tx: Transaction, -) -> JSONPartialTx { - JSONPartialTx { +) -> PartialTx { + PartialTx { amount: receive_amount, blind_sum: util::to_hex(blind_sum.secret_key().as_ref().to_vec()), tx: util::to_hex(ser::ser_vec(&tx).unwrap()), @@ -555,19 +554,14 @@ pub fn build_partial_tx( /// factors and the transaction itself. pub fn read_partial_tx( keychain: &keychain::Keychain, - partial_tx: &JSONPartialTx, + partial_tx: &PartialTx, ) -> Result<(u64, keychain::BlindingFactor, Transaction), Error> { - // let partial_tx: JSONPartialTx = serde_json::from_str(json_str)?; - let blind_bin = util::from_hex(partial_tx.blind_sum.clone())?; - let blinding = keychain::BlindingFactor::from_slice(keychain.secp(), &blind_bin[..])?; - let tx_bin = util::from_hex(partial_tx.tx.clone())?; let tx = ser::deserialize(&mut &tx_bin[..]).map_err(|_| { Error::Format("Could not deserialize transaction, invalid format.".to_string()) })?; - Ok((partial_tx.amount, blinding, tx)) }