mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-02-08 04:11:08 +03:00
remove invoice state from context (#500)
This commit is contained in:
parent
e00c61fd05
commit
9146c17967
6 changed files with 5 additions and 36 deletions
|
@ -141,8 +141,7 @@ where
|
||||||
{
|
{
|
||||||
let mut sl = slate.clone();
|
let mut sl = slate.clone();
|
||||||
let context = w.get_private_context(keychain_mask, sl.id.as_bytes())?;
|
let context = w.get_private_context(keychain_mask, sl.id.as_bytes())?;
|
||||||
let is_invoice = context.is_invoice;
|
if sl.state == SlateState::Invoice2 {
|
||||||
if is_invoice {
|
|
||||||
check_ttl(w, &sl)?;
|
check_ttl(w, &sl)?;
|
||||||
|
|
||||||
let mut temp_ctx = context.clone();
|
let mut temp_ctx = context.clone();
|
||||||
|
|
|
@ -674,7 +674,6 @@ where
|
||||||
if let Ok(c) = context_res {
|
if let Ok(c) = context_res {
|
||||||
context.initial_sec_key = c.initial_sec_key;
|
context.initial_sec_key = c.initial_sec_key;
|
||||||
context.initial_sec_nonce = c.initial_sec_nonce;
|
context.initial_sec_nonce = c.initial_sec_nonce;
|
||||||
context.is_invoice = c.is_invoice;
|
|
||||||
context.fee = c.fee;
|
context.fee = c.fee;
|
||||||
context.amount = c.amount;
|
context.amount = c.amount;
|
||||||
for o in c.output_ids.iter() {
|
for o in c.output_ids.iter() {
|
||||||
|
@ -955,25 +954,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// return whether slate was an invoice tx
|
|
||||||
pub fn context_is_invoice<'a, L, C, K>(
|
|
||||||
wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
|
||||||
keychain_mask: Option<&SecretKey>,
|
|
||||||
slate: &Slate,
|
|
||||||
) -> Result<bool, Error>
|
|
||||||
where
|
|
||||||
L: WalletLCProvider<'a, C, K>,
|
|
||||||
C: NodeClient + 'a,
|
|
||||||
K: Keychain + 'a,
|
|
||||||
{
|
|
||||||
let context = {
|
|
||||||
wallet_lock!(wallet_inst, w);
|
|
||||||
let context = w.get_private_context(keychain_mask, slate.id.as_bytes())?;
|
|
||||||
context
|
|
||||||
};
|
|
||||||
Ok(context.is_invoice)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Experimental, wrap the entire definition of how a wallet's state is updated
|
/// Experimental, wrap the entire definition of how a wallet's state is updated
|
||||||
pub fn update_wallet_state<'a, L, C, K>(
|
pub fn update_wallet_state<'a, L, C, K>(
|
||||||
wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
||||||
|
|
|
@ -47,7 +47,6 @@ pub fn build_send_tx<'a, T: ?Sized, C, K>(
|
||||||
change_outputs: usize,
|
change_outputs: usize,
|
||||||
selection_strategy_is_use_all: bool,
|
selection_strategy_is_use_all: bool,
|
||||||
parent_key_id: Identifier,
|
parent_key_id: Identifier,
|
||||||
is_invoice: bool,
|
|
||||||
use_test_nonce: bool,
|
use_test_nonce: bool,
|
||||||
) -> Result<Context, Error>
|
) -> Result<Context, Error>
|
||||||
where
|
where
|
||||||
|
@ -79,7 +78,6 @@ where
|
||||||
blinding.secret_key(&keychain.secp()).unwrap(),
|
blinding.secret_key(&keychain.secp()).unwrap(),
|
||||||
&parent_key_id,
|
&parent_key_id,
|
||||||
use_test_nonce,
|
use_test_nonce,
|
||||||
is_invoice,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
context.fee = fee;
|
context.fee = fee;
|
||||||
|
@ -238,7 +236,6 @@ pub fn build_recipient_output<'a, T: ?Sized, C, K>(
|
||||||
slate: &mut Slate,
|
slate: &mut Slate,
|
||||||
current_height: u64,
|
current_height: u64,
|
||||||
parent_key_id: Identifier,
|
parent_key_id: Identifier,
|
||||||
is_invoice: bool,
|
|
||||||
use_test_rng: bool,
|
use_test_rng: bool,
|
||||||
) -> Result<(Identifier, Context, TxLogEntry), Error>
|
) -> Result<(Identifier, Context, TxLogEntry), Error>
|
||||||
where
|
where
|
||||||
|
@ -268,7 +265,6 @@ where
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
&parent_key_id,
|
&parent_key_id,
|
||||||
use_test_rng,
|
use_test_rng,
|
||||||
is_invoice,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
context.add_output(&key_id, &None, amount);
|
context.add_output(&key_id, &None, amount);
|
||||||
|
|
|
@ -175,7 +175,6 @@ where
|
||||||
num_change_outputs,
|
num_change_outputs,
|
||||||
selection_strategy_is_use_all,
|
selection_strategy_is_use_all,
|
||||||
parent_key_id.clone(),
|
parent_key_id.clone(),
|
||||||
!is_initiator,
|
|
||||||
use_test_rng,
|
use_test_rng,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -226,7 +225,6 @@ where
|
||||||
slate,
|
slate,
|
||||||
current_height,
|
current_height,
|
||||||
parent_key_id.clone(),
|
parent_key_id.clone(),
|
||||||
is_initiator,
|
|
||||||
use_test_rng,
|
use_test_rng,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
@ -554,8 +554,6 @@ pub struct Context {
|
||||||
pub fee: u64,
|
pub fee: u64,
|
||||||
/// Payment proof sender address derivation path, if needed
|
/// Payment proof sender address derivation path, if needed
|
||||||
pub payment_proof_derivation_index: Option<u32>,
|
pub payment_proof_derivation_index: Option<u32>,
|
||||||
/// whether this was an invoice transaction
|
|
||||||
pub is_invoice: bool,
|
|
||||||
/// for invoice I2 Only, store the tx excess so we can
|
/// for invoice I2 Only, store the tx excess so we can
|
||||||
/// remove it from the slate on return
|
/// remove it from the slate on return
|
||||||
pub calculated_excess: Option<pedersen::Commitment>,
|
pub calculated_excess: Option<pedersen::Commitment>,
|
||||||
|
@ -568,7 +566,6 @@ impl Context {
|
||||||
sec_key: SecretKey,
|
sec_key: SecretKey,
|
||||||
parent_key_id: &Identifier,
|
parent_key_id: &Identifier,
|
||||||
use_test_rng: bool,
|
use_test_rng: bool,
|
||||||
is_invoice: bool,
|
|
||||||
) -> Context {
|
) -> Context {
|
||||||
let sec_nonce = match use_test_rng {
|
let sec_nonce = match use_test_rng {
|
||||||
false => aggsig::create_secnonce(secp).unwrap(),
|
false => aggsig::create_secnonce(secp).unwrap(),
|
||||||
|
@ -585,7 +582,6 @@ impl Context {
|
||||||
amount: 0,
|
amount: 0,
|
||||||
fee: 0,
|
fee: 0,
|
||||||
payment_proof_derivation_index: None,
|
payment_proof_derivation_index: None,
|
||||||
is_invoice,
|
|
||||||
calculated_excess: None,
|
calculated_excess: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ fn aggsig_sender_receiver_interaction() {
|
||||||
|
|
||||||
let blind = blinding_factor.secret_key(&keychain.secp()).unwrap();
|
let blind = blinding_factor.secret_key(&keychain.secp()).unwrap();
|
||||||
|
|
||||||
s_cx = Context::new(&keychain.secp(), blind, &parent, false, false);
|
s_cx = Context::new(&keychain.secp(), blind, &parent, false);
|
||||||
s_cx.get_public_keys(&keychain.secp())
|
s_cx.get_public_keys(&keychain.secp())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ fn aggsig_sender_receiver_interaction() {
|
||||||
// let blind = blind_sum.secret_key(&keychain.secp())?;
|
// let blind = blind_sum.secret_key(&keychain.secp())?;
|
||||||
let blind = keychain.derive_key(0, &key_id, switch).unwrap();
|
let blind = keychain.derive_key(0, &key_id, switch).unwrap();
|
||||||
|
|
||||||
rx_cx = Context::new(&keychain.secp(), blind, &parent, false, false);
|
rx_cx = Context::new(&keychain.secp(), blind, &parent, false);
|
||||||
let (pub_excess, pub_nonce) = rx_cx.get_public_keys(&keychain.secp());
|
let (pub_excess, pub_nonce) = rx_cx.get_public_keys(&keychain.secp());
|
||||||
rx_cx.add_output(&key_id, &None, 0);
|
rx_cx.add_output(&key_id, &None, 0);
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ fn aggsig_sender_receiver_interaction_offset() {
|
||||||
|
|
||||||
let blind = blinding_factor.secret_key(&keychain.secp()).unwrap();
|
let blind = blinding_factor.secret_key(&keychain.secp()).unwrap();
|
||||||
|
|
||||||
s_cx = Context::new(&keychain.secp(), blind, &parent, false, false);
|
s_cx = Context::new(&keychain.secp(), blind, &parent, false);
|
||||||
s_cx.get_public_keys(&keychain.secp())
|
s_cx.get_public_keys(&keychain.secp())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ fn aggsig_sender_receiver_interaction_offset() {
|
||||||
|
|
||||||
let blind = keychain.derive_key(0, &key_id, switch).unwrap();
|
let blind = keychain.derive_key(0, &key_id, switch).unwrap();
|
||||||
|
|
||||||
rx_cx = Context::new(&keychain.secp(), blind, &parent, false, false);
|
rx_cx = Context::new(&keychain.secp(), blind, &parent, false);
|
||||||
let (pub_excess, pub_nonce) = rx_cx.get_public_keys(&keychain.secp());
|
let (pub_excess, pub_nonce) = rx_cx.get_public_keys(&keychain.secp());
|
||||||
rx_cx.add_output(&key_id, &None, 0);
|
rx_cx.add_output(&key_id, &None, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue