mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-21 03:21:08 +03:00
merge from 5.3.0 master release
This commit is contained in:
commit
57bf8be0cb
12 changed files with 531 additions and 494 deletions
686
Cargo.lock
generated
686
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
22
Cargo.toml
22
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet"
|
name = "grin_wallet"
|
||||||
version = "5.2.0-beta.1"
|
version = "5.3.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -30,21 +30,21 @@ semver = "0.10"
|
||||||
rustyline = "6"
|
rustyline = "6"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
|
|
||||||
grin_wallet_api = { path = "./api", version = "5.2.0-beta.1" }
|
grin_wallet_api = { path = "./api", version = "5.3.0" }
|
||||||
grin_wallet_impls = { path = "./impls", version = "5.2.0-beta.1" }
|
grin_wallet_impls = { path = "./impls", version = "5.3.0" }
|
||||||
grin_wallet_libwallet = { path = "./libwallet", version = "5.2.0-beta.1" }
|
grin_wallet_libwallet = { path = "./libwallet", version = "5.3.0" }
|
||||||
grin_wallet_controller = { path = "./controller", version = "5.2.0-beta.1" }
|
grin_wallet_controller = { path = "./controller", version = "5.3.0" }
|
||||||
grin_wallet_config = { path = "./config", version = "5.2.0-beta.1" }
|
grin_wallet_config = { path = "./config", version = "5.3.0" }
|
||||||
grin_wallet_util = { path = "./util", version = "5.2.0-beta.1" }
|
grin_wallet_util = { path = "./util", version = "5.3.0" }
|
||||||
|
|
||||||
|
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
#grin_core = "4.0.0"
|
# grin_core = "5.3.0"
|
||||||
#grin_keychain = "4.0.0"
|
# grin_keychain = "5.3.0"
|
||||||
#grin_util = "4.0.0"
|
# grin_util = "5.3.0"
|
||||||
#grin_api = "4.0.0"
|
# grin_api = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet_api"
|
name = "grin_wallet_api"
|
||||||
version = "5.2.0-beta.1"
|
version = "5.3.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Grin Wallet API"
|
description = "Grin Wallet API"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -22,17 +22,17 @@ ring = "0.16"
|
||||||
base64 = "0.12"
|
base64 = "0.12"
|
||||||
ed25519-dalek = "1.0.0-pre.4"
|
ed25519-dalek = "1.0.0-pre.4"
|
||||||
|
|
||||||
grin_wallet_libwallet = { path = "../libwallet", version = "5.2.0-beta.1" }
|
grin_wallet_libwallet = { path = "../libwallet", version = "5.3.0" }
|
||||||
grin_wallet_config = { path = "../config", version = "5.2.0-beta.1" }
|
grin_wallet_config = { path = "../config", version = "5.3.0" }
|
||||||
grin_wallet_impls = { path = "../impls", version = "5.2.0-beta.1" }
|
grin_wallet_impls = { path = "../impls", version = "5.3.0" }
|
||||||
grin_wallet_util = { path = "../util", version = "5.2.0-beta.1" }
|
grin_wallet_util = { path = "../util", version = "5.3.0" }
|
||||||
|
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
#grin_core = "4.0.0"
|
# grin_core = "5.3.0"
|
||||||
#grin_keychain = "4.0.0"
|
# grin_keychain = "5.3.0"
|
||||||
#grin_util = "4.0.0"
|
# grin_util = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet_config"
|
name = "grin_wallet_config"
|
||||||
version = "5.2.0-beta.1"
|
version = "5.3.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Configuration for grin wallet , a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Configuration for grin wallet , a simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -16,18 +16,18 @@ serde_derive = "1"
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
dirs = "2.0"
|
dirs = "2.0"
|
||||||
|
|
||||||
grin_wallet_util = { path = "../util", version = "5.2.0-beta.1" }
|
grin_wallet_util = { path = "../util", version = "5.3.0" }
|
||||||
|
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
#grin_core = "4.0.0"
|
# grin_core = "5.3.0"
|
||||||
#grin_util = "4.0.0"
|
# grin_util = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
# grin_core = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3"}
|
#grin_core = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3"}
|
||||||
# grin_util = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }
|
#grin_util = { git = "https://github.com/mimblewimble/grin", tag = "v5.2.0-beta.3" }
|
||||||
|
|
||||||
# For bleeding edge
|
# For bleeding edge
|
||||||
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
grin_core = { git = "https://github.com/mimblewimble/grin", branch = "master" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet_controller"
|
name = "grin_wallet_controller"
|
||||||
version = "5.2.0-beta.1"
|
version = "5.3.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Controllers for grin wallet instantiation"
|
description = "Controllers for grin wallet instantiation"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -30,19 +30,19 @@ lazy_static = "1"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
qr_code = "1.1.0"
|
qr_code = "1.1.0"
|
||||||
|
|
||||||
grin_wallet_util = { path = "../util", version = "5.2.0-beta.1" }
|
grin_wallet_util = { path = "../util", version = "5.3.0" }
|
||||||
grin_wallet_api = { path = "../api", version = "5.2.0-beta.1" }
|
grin_wallet_api = { path = "../api", version = "5.3.0" }
|
||||||
grin_wallet_impls = { path = "../impls", version = "5.2.0-beta.1" }
|
grin_wallet_impls = { path = "../impls", version = "5.3.0" }
|
||||||
grin_wallet_libwallet = { path = "../libwallet", version = "5.2.0-beta.1" }
|
grin_wallet_libwallet = { path = "../libwallet", version = "5.3.0" }
|
||||||
grin_wallet_config = { path = "../config", version = "5.2.0-beta.1" }
|
grin_wallet_config = { path = "../config", version = "5.3.0" }
|
||||||
|
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
#grin_core = "4.0.0"
|
# grin_core = "5.3.0"
|
||||||
#grin_keychain = "4.0.0"
|
# grin_keychain = "5.3.0"
|
||||||
#grin_util = "4.0.0"
|
# grin_util = "5.3.0"
|
||||||
#grin_api = "4.0.0"
|
# grin_api = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ remove_dir_all = "0.7"
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
# grin_chain = "4.0.0"
|
# grin_chain = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,87 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||||
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 3, false);
|
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 3, false);
|
||||||
//bh += 3;
|
//bh += 3;
|
||||||
|
|
||||||
|
// As above, but use owner API to finalize
|
||||||
|
let mut slate = Slate::blank(2, true);
|
||||||
|
|
||||||
|
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
|
||||||
|
// Wallet 2 inititates an invoice transaction, requesting payment
|
||||||
|
let args = IssueInvoiceTxArgs {
|
||||||
|
amount: reward * 2,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
slate = api.issue_invoice_tx(m, args)?;
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
assert_eq!(slate.state, SlateState::Invoice1);
|
||||||
|
|
||||||
|
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
|
||||||
|
// Wallet 1 receives the invoice transaction
|
||||||
|
let args = InitTxArgs {
|
||||||
|
src_acct_name: None,
|
||||||
|
amount: slate.amount,
|
||||||
|
minimum_confirmations: 2,
|
||||||
|
max_outputs: 500,
|
||||||
|
num_change_outputs: 1,
|
||||||
|
selection_strategy_is_use_all: true,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
slate = api.process_invoice_tx(m, &slate, args)?;
|
||||||
|
api.tx_lock_outputs(m, &slate)?;
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
assert_eq!(slate.state, SlateState::Invoice2);
|
||||||
|
|
||||||
|
// wallet 2 finalizes via owner API
|
||||||
|
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
|
||||||
|
// Wallet 2 receives the invoice transaction
|
||||||
|
slate = api.finalize_tx(m, &slate)?;
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
assert_eq!(slate.state, SlateState::Invoice3);
|
||||||
|
|
||||||
|
// test that payee can only cancel once
|
||||||
|
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 3, false);
|
||||||
|
bh += 3;
|
||||||
|
|
||||||
|
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
|
||||||
|
// Wallet 2 inititates an invoice transaction, requesting payment
|
||||||
|
let args = IssueInvoiceTxArgs {
|
||||||
|
amount: reward * 2,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
slate = api.issue_invoice_tx(m, args)?;
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
assert_eq!(slate.state, SlateState::Invoice1);
|
||||||
|
|
||||||
|
let orig_slate = slate.clone();
|
||||||
|
|
||||||
|
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
|
||||||
|
// Wallet 1 receives the invoice transaction
|
||||||
|
let args = InitTxArgs {
|
||||||
|
src_acct_name: None,
|
||||||
|
amount: slate.amount,
|
||||||
|
minimum_confirmations: 2,
|
||||||
|
max_outputs: 500,
|
||||||
|
num_change_outputs: 1,
|
||||||
|
selection_strategy_is_use_all: true,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
slate = api.process_invoice_tx(m, &slate, args.clone())?;
|
||||||
|
api.tx_lock_outputs(m, &slate)?;
|
||||||
|
|
||||||
|
// Wallet 1 cancels the invoice transaction
|
||||||
|
api.cancel_tx(m, None, Some(slate.id))?;
|
||||||
|
|
||||||
|
// Wallet 1 attempts to repay again
|
||||||
|
let res = api.process_invoice_tx(m, &orig_slate, args);
|
||||||
|
assert!(res.is_err());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})?;
|
||||||
|
assert_eq!(slate.state, SlateState::Invoice2);
|
||||||
|
|
||||||
// let logging finish
|
// let logging finish
|
||||||
stopper.store(false, Ordering::Relaxed);
|
stopper.store(false, Ordering::Relaxed);
|
||||||
thread::sleep(Duration::from_millis(200));
|
thread::sleep(Duration::from_millis(200));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet_impls"
|
name = "grin_wallet_impls"
|
||||||
version = "5.2.0-beta.1"
|
version = "5.3.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Concrete types derived from libwallet traits"
|
description = "Concrete types derived from libwallet traits"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -36,19 +36,19 @@ sysinfo = "0.29"
|
||||||
base64 = "0.12.0"
|
base64 = "0.12.0"
|
||||||
url = "2.1"
|
url = "2.1"
|
||||||
|
|
||||||
grin_wallet_util = { path = "../util", version = "5.2.0-beta.1" }
|
grin_wallet_util = { path = "../util", version = "5.3.0" }
|
||||||
grin_wallet_config = { path = "../config", version = "5.2.0-beta.1" }
|
grin_wallet_config = { path = "../config", version = "5.3.0" }
|
||||||
grin_wallet_libwallet = { path = "../libwallet", version = "5.2.0-beta.1" }
|
grin_wallet_libwallet = { path = "../libwallet", version = "5.3.0" }
|
||||||
|
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
#grin_core = "4.0.0"
|
# grin_core = "5.3.0"
|
||||||
#grin_keychain = "4.0.0"
|
# grin_keychain = "5.3.0"
|
||||||
#grin_chain = "4.0.0"
|
# grin_chain = "5.3.0"
|
||||||
#grin_util = "4.0.0"
|
# grin_util = "5.3.0"
|
||||||
#grin_api = "4.0.0"
|
# grin_api = "5.3.0"
|
||||||
#grin_store = "4.0.0"
|
# grin_store = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet_libwallet"
|
name = "grin_wallet_libwallet"
|
||||||
version = "5.2.0-beta.1"
|
version = "5.3.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
description = "Simple, private and scalable cryptocurrency implementation based on the MimbleWimble chain format."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -37,21 +37,22 @@ bech32 = "0.7"
|
||||||
byteorder = "1.3"
|
byteorder = "1.3"
|
||||||
num-bigint = "0.2"
|
num-bigint = "0.2"
|
||||||
|
|
||||||
|
grin_wallet_util = { path = "../util", version = "5.3.0" }
|
||||||
|
grin_wallet_config = { path = "../config", version = "5.3.0" }
|
||||||
|
|
||||||
|
grin_secp256k1zkp = { version = "0.7.12", features = ["bullet-proof-sizing"]}
|
||||||
|
|
||||||
#mwmixnet onion
|
#mwmixnet onion
|
||||||
chacha20 = "0.8.1"
|
chacha20 = "0.8.1"
|
||||||
hmac = { version = "0.12.0", features = ["std"]}
|
hmac = { version = "0.12.0", features = ["std"]}
|
||||||
|
|
||||||
grin_secp256k1zkp = { version = "0.7.12", features = ["bullet-proof-sizing"]}
|
|
||||||
|
|
||||||
grin_wallet_util = { path = "../util", version = "5.2.0-beta.1" }
|
|
||||||
grin_wallet_config = { path = "../config", version = "5.2.0-beta.1" }
|
|
||||||
|
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
#grin_core = "4.0.0"
|
# grin_core = "5.3.0"
|
||||||
#grin_keychain = "4.0.0"
|
# grin_keychain = "5.3.0"
|
||||||
#grin_util = "4.0.0"
|
# grin_util = "5.3.0"
|
||||||
|
# grin_store = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::api_impl::owner::contract_new as owner_contract_new;
|
use crate::api_impl::owner::contract_new as owner_contract_new;
|
||||||
use crate::api_impl::owner::contract_sign as owner_contract_sign;
|
use crate::api_impl::owner::contract_sign as owner_contract_sign;
|
||||||
use crate::api_impl::owner::finalize_tx as owner_finalize;
|
|
||||||
use crate::api_impl::owner::{check_ttl, post_tx};
|
use crate::api_impl::owner::{check_ttl, post_tx};
|
||||||
use crate::contract::proofs::InvoiceProof;
|
use crate::contract::proofs::InvoiceProof;
|
||||||
use crate::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
|
use crate::contract::types::{ContractNewArgsAPI, ContractSetupArgsAPI};
|
||||||
|
@ -32,6 +31,8 @@ use crate::{
|
||||||
};
|
};
|
||||||
use ed25519_dalek::PublicKey as DalekPublicKey;
|
use ed25519_dalek::PublicKey as DalekPublicKey;
|
||||||
|
|
||||||
|
use super::owner::tx_lock_outputs;
|
||||||
|
|
||||||
const FOREIGN_API_VERSION: u16 = 2;
|
const FOREIGN_API_VERSION: u16 = 2;
|
||||||
|
|
||||||
/// Return the version info
|
/// Return the version info
|
||||||
|
@ -151,10 +152,9 @@ where
|
||||||
K: Keychain + 'a,
|
K: Keychain + 'a,
|
||||||
{
|
{
|
||||||
let mut sl = slate.clone();
|
let mut sl = slate.clone();
|
||||||
let context = w.get_private_context(keychain_mask, sl.id.as_bytes())?;
|
let mut context = w.get_private_context(keychain_mask, sl.id.as_bytes())?;
|
||||||
if sl.state == SlateState::Invoice2 {
|
|
||||||
check_ttl(w, &sl)?;
|
check_ttl(w, &sl)?;
|
||||||
|
if sl.state == SlateState::Invoice2 {
|
||||||
// Add our contribution to the offset
|
// Add our contribution to the offset
|
||||||
sl.adjust_offset(&w.keychain(keychain_mask)?, &context)?;
|
sl.adjust_offset(&w.keychain(keychain_mask)?, &context)?;
|
||||||
|
|
||||||
|
@ -172,8 +172,66 @@ where
|
||||||
}
|
}
|
||||||
sl.state = SlateState::Invoice3;
|
sl.state = SlateState::Invoice3;
|
||||||
sl.amount = 0;
|
sl.amount = 0;
|
||||||
|
} else if sl.state == SlateState::Standard2 {
|
||||||
|
let keychain = w.keychain(keychain_mask)?;
|
||||||
|
let parent_key_id = w.parent_key_id();
|
||||||
|
|
||||||
|
if let Some(args) = context.late_lock_args.take() {
|
||||||
|
// Transaction was late locked, select inputs+change now
|
||||||
|
// and insert into original context
|
||||||
|
|
||||||
|
let current_height = w.w2n_client().get_chain_tip()?.0;
|
||||||
|
let mut temp_sl =
|
||||||
|
tx::new_tx_slate(&mut *w, context.amount, false, 2, false, args.ttl_blocks)?;
|
||||||
|
let temp_context = selection::build_send_tx(
|
||||||
|
w,
|
||||||
|
&keychain,
|
||||||
|
keychain_mask,
|
||||||
|
&mut temp_sl,
|
||||||
|
current_height,
|
||||||
|
args.minimum_confirmations,
|
||||||
|
args.max_outputs as usize,
|
||||||
|
args.num_change_outputs as usize,
|
||||||
|
args.selection_strategy_is_use_all,
|
||||||
|
Some(context.fee.map(|f| f.fee()).unwrap_or(0)),
|
||||||
|
parent_key_id.clone(),
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Add inputs and outputs to original context
|
||||||
|
context.input_ids = temp_context.input_ids;
|
||||||
|
context.output_ids = temp_context.output_ids;
|
||||||
|
|
||||||
|
// Store the updated context
|
||||||
|
{
|
||||||
|
let mut batch = w.batch(keychain_mask)?;
|
||||||
|
batch.save_private_context(sl.id.as_bytes(), &context)?;
|
||||||
|
batch.commit()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now do the actual locking
|
||||||
|
tx_lock_outputs(w, keychain_mask, &sl)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add our contribution to the offset
|
||||||
|
sl.adjust_offset(&keychain, &context)?;
|
||||||
|
|
||||||
|
selection::repopulate_tx(&mut *w, keychain_mask, &mut sl, &context, true)?;
|
||||||
|
|
||||||
|
tx::complete_tx(&mut *w, keychain_mask, &mut sl, &context)?;
|
||||||
|
tx::verify_slate_payment_proof(&mut *w, keychain_mask, &parent_key_id, &context, &sl)?;
|
||||||
|
tx::update_stored_tx(&mut *w, keychain_mask, &context, &sl, false)?;
|
||||||
|
{
|
||||||
|
let mut batch = w.batch(keychain_mask)?;
|
||||||
|
batch.delete_private_context(sl.id.as_bytes())?;
|
||||||
|
batch.commit()?;
|
||||||
|
}
|
||||||
|
sl.state = SlateState::Standard3;
|
||||||
|
sl.amount = 0;
|
||||||
} else {
|
} else {
|
||||||
sl = owner_finalize(w, keychain_mask, slate)?;
|
return Err(Error::SlateState);
|
||||||
}
|
}
|
||||||
if post_automatically {
|
if post_automatically {
|
||||||
post_tx(w.w2n_client(), sl.tx_or_err()?, true)?;
|
post_tx(w.w2n_client(), sl.tx_or_err()?, true)?;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::api_impl::foreign::finalize_tx as foreign_finalize;
|
||||||
use crate::contract::proofs::{InvoiceProof, ProofWitness};
|
use crate::contract::proofs::{InvoiceProof, ProofWitness};
|
||||||
use crate::grin_core::core::hash::Hashed;
|
use crate::grin_core::core::hash::Hashed;
|
||||||
use crate::grin_core::core::{Output, OutputFeatures, Transaction};
|
use crate::grin_core::core::{Output, OutputFeatures, Transaction};
|
||||||
|
@ -831,6 +832,9 @@ where
|
||||||
if t.tx_type == TxLogEntryType::TxSent {
|
if t.tx_type == TxLogEntryType::TxSent {
|
||||||
return Err(Error::TransactionAlreadyReceived(ret_slate.id.to_string()));
|
return Err(Error::TransactionAlreadyReceived(ret_slate.id.to_string()));
|
||||||
}
|
}
|
||||||
|
if t.tx_type == TxLogEntryType::TxSentCancelled {
|
||||||
|
return Err(Error::TransactionWasCancelled(ret_slate.id.to_string()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let height = w.w2n_client().get_chain_tip()?.0;
|
let height = w.w2n_client().get_chain_tip()?.0;
|
||||||
|
@ -959,68 +963,7 @@ where
|
||||||
C: NodeClient + 'a,
|
C: NodeClient + 'a,
|
||||||
K: Keychain + 'a,
|
K: Keychain + 'a,
|
||||||
{
|
{
|
||||||
let mut sl = slate.clone();
|
foreign_finalize(w, keychain_mask, slate, false)
|
||||||
check_ttl(w, &sl)?;
|
|
||||||
let mut context = w.get_private_context(keychain_mask, sl.id.as_bytes())?;
|
|
||||||
let keychain = w.keychain(keychain_mask)?;
|
|
||||||
let parent_key_id = w.parent_key_id();
|
|
||||||
|
|
||||||
if let Some(args) = context.late_lock_args.take() {
|
|
||||||
// Transaction was late locked, select inputs+change now
|
|
||||||
// and insert into original context
|
|
||||||
|
|
||||||
let current_height = w.w2n_client().get_chain_tip()?.0;
|
|
||||||
let mut temp_sl =
|
|
||||||
tx::new_tx_slate(&mut *w, context.amount, false, 2, false, args.ttl_blocks)?;
|
|
||||||
let temp_context = selection::build_send_tx(
|
|
||||||
w,
|
|
||||||
&keychain,
|
|
||||||
keychain_mask,
|
|
||||||
&mut temp_sl,
|
|
||||||
current_height,
|
|
||||||
args.minimum_confirmations,
|
|
||||||
args.max_outputs as usize,
|
|
||||||
args.num_change_outputs as usize,
|
|
||||||
args.selection_strategy_is_use_all,
|
|
||||||
Some(context.fee.map(|f| f.fee()).unwrap_or(0)),
|
|
||||||
parent_key_id.clone(),
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
// Add inputs and outputs to original context
|
|
||||||
context.input_ids = temp_context.input_ids;
|
|
||||||
context.output_ids = temp_context.output_ids;
|
|
||||||
|
|
||||||
// Store the updated context
|
|
||||||
{
|
|
||||||
let mut batch = w.batch(keychain_mask)?;
|
|
||||||
batch.save_private_context(sl.id.as_bytes(), &context)?;
|
|
||||||
batch.commit()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now do the actual locking
|
|
||||||
tx_lock_outputs(w, keychain_mask, &sl)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add our contribution to the offset
|
|
||||||
sl.adjust_offset(&keychain, &context)?;
|
|
||||||
|
|
||||||
selection::repopulate_tx(&mut *w, keychain_mask, &mut sl, &context, true)?;
|
|
||||||
|
|
||||||
tx::complete_tx(&mut *w, keychain_mask, &mut sl, &context)?;
|
|
||||||
tx::verify_slate_payment_proof(&mut *w, keychain_mask, &parent_key_id, &context, &sl)?;
|
|
||||||
tx::update_stored_tx(&mut *w, keychain_mask, &context, &sl, false)?;
|
|
||||||
{
|
|
||||||
let mut batch = w.batch(keychain_mask)?;
|
|
||||||
batch.delete_private_context(sl.id.as_bytes())?;
|
|
||||||
batch.commit()?;
|
|
||||||
}
|
|
||||||
sl.state = SlateState::Standard3;
|
|
||||||
sl.amount = 0;
|
|
||||||
|
|
||||||
Ok(sl)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cancel tx
|
/// cancel tx
|
||||||
|
|
|
@ -161,6 +161,10 @@ pub enum Error {
|
||||||
#[error("Transaction {0} has already been received")]
|
#[error("Transaction {0} has already been received")]
|
||||||
TransactionAlreadyReceived(String),
|
TransactionAlreadyReceived(String),
|
||||||
|
|
||||||
|
/// Transaction has been cancelled
|
||||||
|
#[error("Transaction {0} has been cancelled")]
|
||||||
|
TransactionWasCancelled(String),
|
||||||
|
|
||||||
/// Attempt to repost a transaction that's not completed and stored
|
/// Attempt to repost a transaction that's not completed and stored
|
||||||
#[error("Transaction building not completed: {0}")]
|
#[error("Transaction building not completed: {0}")]
|
||||||
TransactionBuildingNotCompleted(u32),
|
TransactionBuildingNotCompleted(u32),
|
||||||
|
@ -197,6 +201,10 @@ pub enum Error {
|
||||||
#[error("Can't Deserialize slate")]
|
#[error("Can't Deserialize slate")]
|
||||||
SlateDeser,
|
SlateDeser,
|
||||||
|
|
||||||
|
/// Invalid slate state
|
||||||
|
#[error("Invalid slate state")]
|
||||||
|
SlateState,
|
||||||
|
|
||||||
/// Can't serialize slate pack
|
/// Can't serialize slate pack
|
||||||
#[error("Can't Serialize slatepack")]
|
#[error("Can't Serialize slatepack")]
|
||||||
SlatepackSer,
|
SlatepackSer,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "grin_wallet_util"
|
name = "grin_wallet_util"
|
||||||
version = "5.2.0-beta.1"
|
version = "5.3.0"
|
||||||
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
authors = ["Grin Developers <mimblewimble@lists.launchpad.net>"]
|
||||||
description = "Util, for generic utilities and to re-export grin crates"
|
description = "Util, for generic utilities and to re-export grin crates"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
@ -21,7 +21,7 @@ thiserror = "1"
|
||||||
##### Grin Imports
|
##### Grin Imports
|
||||||
|
|
||||||
# For Release
|
# For Release
|
||||||
#grin_util = "4.0.0"
|
# grin_util = "5.3.0"
|
||||||
|
|
||||||
# For beta release
|
# For beta release
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue