mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-02-01 08:51:09 +03:00
Check stored transaction for payment proof when checking proof (#266)
* check original transaction when checking payment proof * rustfmt * tweak to trigger build
This commit is contained in:
parent
56396b85ff
commit
0d77282398
3 changed files with 28 additions and 16 deletions
|
@ -23,4 +23,3 @@ Full documentation outlining how to use the command line wallet can be found on
|
||||||
# License
|
# License
|
||||||
|
|
||||||
Apache License v2.0
|
Apache License v2.0
|
||||||
|
|
||||||
|
|
|
@ -474,7 +474,30 @@ where
|
||||||
C: NodeClient + 'a,
|
C: NodeClient + 'a,
|
||||||
K: Keychain + 'a,
|
K: Keychain + 'a,
|
||||||
{
|
{
|
||||||
|
let tx_vec = updater::retrieve_txs(wallet, None, Some(slate.id), Some(parent_key_id), false)?;
|
||||||
|
if tx_vec.len() == 0 {
|
||||||
|
return Err(ErrorKind::PaymentProof(
|
||||||
|
"TxLogEntry with original proof info not found (is account correct?)".to_owned(),
|
||||||
|
))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let orig_proof_info = tx_vec[0].clone().payment_proof;
|
||||||
|
|
||||||
|
if orig_proof_info.is_some() && slate.payment_proof.is_none() {
|
||||||
|
return Err(ErrorKind::PaymentProof(
|
||||||
|
"Expected Payment Proof for this Transaction is not present".to_owned(),
|
||||||
|
))?;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref p) = slate.payment_proof {
|
if let Some(ref p) = slate.payment_proof {
|
||||||
|
let orig_proof_info = match orig_proof_info {
|
||||||
|
Some(p) => p,
|
||||||
|
None => {
|
||||||
|
return Err(ErrorKind::PaymentProof(
|
||||||
|
"Original proof info not stored in tx".to_owned(),
|
||||||
|
))?;
|
||||||
|
}
|
||||||
|
};
|
||||||
let keychain = wallet.keychain(keychain_mask)?;
|
let keychain = wallet.keychain(keychain_mask)?;
|
||||||
let index = match context.payment_proof_derivation_index {
|
let index = match context.payment_proof_derivation_index {
|
||||||
Some(i) => i,
|
Some(i) => i,
|
||||||
|
@ -492,21 +515,7 @@ where
|
||||||
"Sender address on slate does not match original sender address".to_owned(),
|
"Sender address on slate does not match original sender address".to_owned(),
|
||||||
))?;
|
))?;
|
||||||
}
|
}
|
||||||
let tx_vec =
|
|
||||||
updater::retrieve_txs(wallet, None, Some(slate.id), Some(&parent_key_id), false)?;
|
|
||||||
if tx_vec.len() != 1 {
|
|
||||||
return Err(ErrorKind::PaymentProof(
|
|
||||||
"TxLogEntry with original proof info not found".to_owned(),
|
|
||||||
))?;
|
|
||||||
}
|
|
||||||
let orig_proof_info = match tx_vec[0].clone().payment_proof {
|
|
||||||
Some(o) => o,
|
|
||||||
None => {
|
|
||||||
return Err(ErrorKind::PaymentProof(
|
|
||||||
"Original proof info not stored in tx".to_owned(),
|
|
||||||
))?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if orig_proof_info.receiver_address != p.receiver_address {
|
if orig_proof_info.receiver_address != p.receiver_address {
|
||||||
return Err(ErrorKind::PaymentProof(
|
return Err(ErrorKind::PaymentProof(
|
||||||
"Recipient address on slate does not match original recipient address".to_owned(),
|
"Recipient address on slate does not match original recipient address".to_owned(),
|
||||||
|
|
|
@ -213,6 +213,8 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
|
||||||
|
|
||||||
let arg_vec = vec![
|
let arg_vec = vec![
|
||||||
"grin-wallet",
|
"grin-wallet",
|
||||||
|
"-a",
|
||||||
|
"mining",
|
||||||
"-p",
|
"-p",
|
||||||
"password",
|
"password",
|
||||||
"finalize",
|
"finalize",
|
||||||
|
@ -307,6 +309,8 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller::
|
||||||
|
|
||||||
let arg_vec = vec![
|
let arg_vec = vec![
|
||||||
"grin-wallet",
|
"grin-wallet",
|
||||||
|
"-a",
|
||||||
|
"mining",
|
||||||
"-p",
|
"-p",
|
||||||
"password",
|
"password",
|
||||||
"finalize",
|
"finalize",
|
||||||
|
|
Loading…
Reference in a new issue