Slatepack Workflow (#423)

* debugging tor sends

* use fixed yeast version of hyper-socks2

* send command working according to slatepack

* changes to handling proof address

* modifications of recieve command to work with slatepack and to attempt to return to sender via TOR

* finalize command tested

* attempting to add invoice processing

* fixes to tests, propagation of test mode where needed

* modify return values of api functions that can send as sync

* cleanup, testing and post_tx function

* revert changes to API, many test fixes

* deprecate http on the command-line warning
This commit is contained in:
Yeastplume
2020-06-03 08:39:23 +01:00
committed by GitHub
parent 4fe6bf1c23
commit 60ab3728ab
28 changed files with 1425 additions and 738 deletions
+29 -19
View File
@@ -15,7 +15,8 @@
//! Generic implementation of owner API functions
use strum::IntoEnumIterator;
use crate::api_impl::owner::check_ttl;
use crate::api_impl::owner::finalize_tx as owner_finalize;
use crate::api_impl::owner::{check_ttl, post_tx};
use crate::grin_core::core::transaction::Transaction;
use crate::grin_keychain::Keychain;
use crate::grin_util::secp::key::SecretKey;
@@ -132,11 +133,12 @@ where
Ok(ret_slate)
}
/// Receive an tx that this wallet has issued
pub fn finalize_invoice_tx<'a, T: ?Sized, C, K>(
/// Receive a tx that this wallet has issued
pub fn finalize_tx<'a, T: ?Sized, C, K>(
w: &mut T,
keychain_mask: Option<&SecretKey>,
slate: &Slate,
post_automatically: bool,
) -> Result<Slate, Error>
where
T: WalletBackend<'a, C, K>,
@@ -144,24 +146,32 @@ where
K: Keychain + 'a,
{
let mut sl = slate.clone();
check_ttl(w, &sl)?;
let context = w.get_private_context(keychain_mask, sl.id.as_bytes())?;
if sl.is_compact() {
let mut temp_ctx = context.clone();
temp_ctx.sec_key = context.initial_sec_key.clone();
temp_ctx.sec_nonce = context.initial_sec_nonce.clone();
selection::repopulate_tx(&mut *w, keychain_mask, &mut sl, &temp_ctx, false)?;
let is_invoice = context.is_invoice;
if is_invoice {
check_ttl(w, &sl)?;
if sl.is_compact() {
let mut temp_ctx = context.clone();
temp_ctx.sec_key = context.initial_sec_key.clone();
temp_ctx.sec_nonce = context.initial_sec_nonce.clone();
selection::repopulate_tx(&mut *w, keychain_mask, &mut sl, &temp_ctx, false)?;
}
tx::complete_tx(&mut *w, keychain_mask, &mut sl, &context)?;
tx::update_stored_tx(&mut *w, keychain_mask, &context, &mut sl, true)?;
{
let mut batch = w.batch(keychain_mask)?;
batch.delete_private_context(sl.id.as_bytes())?;
batch.commit()?;
}
sl.state = SlateState::Invoice3;
if sl.is_compact() {
sl.amount = 0;
}
} else {
sl = owner_finalize(w, keychain_mask, slate)?;
}
tx::complete_tx(&mut *w, keychain_mask, &mut sl, &context)?;
tx::update_stored_tx(&mut *w, keychain_mask, &context, &mut sl, true)?;
{
let mut batch = w.batch(keychain_mask)?;
batch.delete_private_context(sl.id.as_bytes())?;
batch.commit()?;
}
sl.state = SlateState::Invoice3;
if sl.is_compact() {
sl.amount = 0;
if post_automatically {
post_tx(w.w2n_client(), sl.tx_or_err()?, true)?;
}
Ok(sl)
}
-4
View File
@@ -80,12 +80,8 @@ pub struct InitTxArgs {
/// in one go
#[derive(Clone, Serialize, Deserialize)]
pub struct InitTxSendArgs {
/// The transaction method. Can currently be 'http' or 'keybase'.
pub method: String,
/// The destination, contents will depend on the particular method
pub dest: String,
/// Whether to finalize the result immediately if the send was successful
pub finalize: bool,
/// Whether to post the transasction if the send and finalize were successful
pub post_tx: bool,
/// Whether to use dandelion when posting. If false, skip the dandelion relay