Foreign API documentation and small cleanup (#31)

* verify slate messages documentation

* rustfmt

* foreign API documentation

* rustfmt
This commit is contained in:
Yeastplume
2019-03-29 08:46:12 +00:00
committed by GitHub
parent f756b10d78
commit 7b8fe92f53
13 changed files with 360 additions and 88 deletions
+15 -7
View File
@@ -44,16 +44,17 @@ pub fn verify_slate_messages(slate: &Slate) -> Result<(), Error> {
/// Receive a tx as recipient
pub fn receive_tx<T: ?Sized, C, K>(
w: &mut T,
slate: &mut Slate,
slate: &Slate,
dest_acct_name: Option<&str>,
message: Option<String>,
use_test_rng: bool,
) -> Result<(), Error>
) -> Result<Slate, Error>
where
T: WalletBackend<C, K>,
C: NodeClient,
K: Keychain,
{
let mut ret_slate = slate.clone();
let parent_key_id = match dest_acct_name {
Some(d) => {
let pm = w.get_acct_path(d.to_owned())?;
@@ -68,13 +69,13 @@ where
let tx = updater::retrieve_txs(
&mut *w,
None,
Some(slate.id),
Some(ret_slate.id),
Some(&parent_key_id),
use_test_rng,
)?;
for t in &tx {
if t.tx_type == TxLogEntryType::TxReceived {
return Err(ErrorKind::TransactionAlreadyReceived(slate.id.to_string()).into());
return Err(ErrorKind::TransactionAlreadyReceived(ret_slate.id.to_string()).into());
}
}
@@ -86,7 +87,14 @@ where
None => None,
};
tx::add_output_to_slate(&mut *w, slate, &parent_key_id, 1, message, use_test_rng)?;
tx::update_message(&mut *w, slate)?;
Ok(())
tx::add_output_to_slate(
&mut *w,
&mut ret_slate,
&parent_key_id,
1,
message,
use_test_rng,
)?;
tx::update_message(&mut *w, &mut ret_slate)?;
Ok(ret_slate)
}