Move libtx to core

This commit is contained in:
Dobby the House Elf 2018-12-05 09:41:26 -08:00 committed by Ignotus Peverell
parent a3523028dc
commit b8124676c7
45 changed files with 72 additions and 80 deletions

2
Cargo.lock generated
View file

@ -778,7 +778,6 @@ dependencies = [
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"grin_keychain 0.4.2",
"grin_util 0.4.2",
"grin_wallet 0.4.2",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -788,6 +787,7 @@ dependencies = [
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]

View file

@ -35,7 +35,7 @@ use core::global::{self, ChainTypes};
use core::pow::{self, Difficulty};
use core::{consensus, genesis};
use keychain::{ExtKeychain, ExtKeychainPath, Keychain};
use wallet::libtx;
use core::libtx;
fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);

View file

@ -35,7 +35,7 @@ use core::global::ChainTypes;
use core::pow::Difficulty;
use core::{consensus, global, pow};
use keychain::{ExtKeychain, ExtKeychainPath, Keychain};
use wallet::libtx::{self, build};
use core::libtx::{self, build};
fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);

View file

@ -29,7 +29,7 @@ use core::core::Block;
use core::global::{self, ChainTypes};
use core::pow::{self, Difficulty};
use keychain::{ExtKeychain, ExtKeychainPath, Keychain};
use wallet::libtx;
use core::libtx;
fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);

View file

@ -35,7 +35,7 @@ use core::global::{self, ChainTypes};
use core::pow::Difficulty;
use core::{consensus, pow};
use keychain::{ExtKeychain, ExtKeychainPath, Keychain};
use wallet::libtx::{self, build};
use core::libtx::{self, build};
fn clean_output_dir(dir_name: &str) {
let _ = fs::remove_dir_all(dir_name);

View file

@ -24,11 +24,9 @@ rand = "0.5"
serde = "1"
serde_derive = "1"
siphasher = "0.2"
uuid = { version = "0.6", features = ["serde", "v4"] }
log = "0.4"
chrono = "0.4.4"
grin_keychain = { path = "../keychain" }
grin_util = { path = "../util" }
[dev-dependencies]
grin_wallet = { path = "../wallet" }

View file

@ -7,8 +7,8 @@ use grin_core::core::{Block, BlockHeader, CompactBlock, Transaction};
use grin_core::ser;
use grin_keychain::keychain::ExtKeychain;
use grin_keychain::Keychain;
use grin_wallet::libtx::build::{input, output, transaction, with_fee};
use grin_wallet::libtx::reward;
use grin_core::libtx::build::{input, output, transaction, with_fee};
use grin_core::libtx::reward;
use std::fs::{self, File};
use std::path::Path;

View file

@ -39,6 +39,7 @@ extern crate serde_derive;
extern crate siphasher;
#[macro_use]
extern crate log;
extern crate uuid;
extern crate chrono;
extern crate failure;
#[macro_use]
@ -51,5 +52,6 @@ pub mod consensus;
pub mod core;
pub mod genesis;
pub mod global;
pub mod libtx;
pub mod pow;
pub mod ser;

View file

@ -32,9 +32,9 @@ use util::secp::{self, aggsig, Message, Secp256k1, Signature};
/// # Example
///
/// ```
/// # extern crate grin_core as core;
/// # extern crate grin_util as util;
/// # extern crate grin_wallet as wallet;
/// use wallet::libtx::aggsig;
/// use core::libtx::aggsig;
/// use util::secp::{ContextFlag, Secp256k1};
/// let secp = Secp256k1::with_caps(ContextFlag::SignOnly);
/// let secret_nonce = aggsig::create_secnonce(&secp).unwrap();
@ -66,11 +66,11 @@ pub fn create_secnonce(secp: &Secp256k1) -> Result<SecretKey, Error> {
/// # Example
///
/// ```
/// # extern crate grin_core as core;
/// # extern crate grin_util as util;
/// # extern crate grin_wallet as wallet;
/// # extern crate rand;
/// use rand::thread_rng;
/// use wallet::libtx::aggsig;
/// use core::libtx::aggsig;
/// use util::secp::key::{PublicKey, SecretKey};
/// use util::secp::{ContextFlag, Secp256k1, Message};
///
@ -137,11 +137,11 @@ pub fn calculate_partial_sig(
/// # Example
///
/// ```
/// # extern crate grin_core as core;
/// # extern crate grin_util as util;
/// # extern crate grin_wallet as wallet;
/// # extern crate rand;
/// use rand::thread_rng;
/// use wallet::libtx::aggsig;
/// use core::libtx::aggsig;
/// use util::secp::key::{PublicKey, SecretKey};
/// use util::secp::{ContextFlag, Secp256k1, Message};
///
@ -224,12 +224,11 @@ pub fn verify_partial_sig(
/// ```
/// # extern crate grin_util as util;
/// # extern crate grin_core as core;
/// # extern crate grin_wallet as wallet;
/// # extern crate grin_keychain as keychain;
/// use core::consensus::reward;
/// use wallet::libtx::{aggsig, proof};
/// use util::secp::key::{PublicKey, SecretKey};
/// use util::secp::{ContextFlag, Secp256k1};
/// use core::libtx::{aggsig, proof};
/// use core::core::transaction::kernel_sig_msg;
/// use core::core::{Output, OutputFeatures};
/// use keychain::{Keychain, ExtKeychain};
@ -297,10 +296,9 @@ where
/// ```
/// # extern crate grin_util as util;
/// # extern crate grin_core as core;
/// # extern crate grin_wallet as wallet;
/// # extern crate grin_keychain as keychain;
/// use core::consensus::reward;
/// use wallet::libtx::{aggsig, proof};
/// use core::libtx::{aggsig, proof};
/// use util::secp::key::{PublicKey, SecretKey};
/// use util::secp::{ContextFlag, Secp256k1};
/// use core::core::transaction::kernel_sig_msg;
@ -368,11 +366,11 @@ pub fn verify_single_from_commit(
/// # Example
///
/// ```
/// # extern crate grin_core as core;
/// # extern crate grin_util as util;
/// # extern crate grin_wallet as wallet;
/// # extern crate rand;
/// use rand::thread_rng;
/// use wallet::libtx::aggsig;
/// use core::libtx::aggsig;
/// use util::secp::key::{PublicKey, SecretKey};
/// use util::secp::{ContextFlag, Secp256k1, Message};
///

View file

@ -25,7 +25,7 @@
//! build::transaction(vec![input_rand(75), output_rand(42), output_rand(32),
//! with_fee(1)])
use core::core::{Input, Output, OutputFeatures, Transaction, TxKernel};
use core::{Input, Output, OutputFeatures, Transaction, TxKernel};
use keychain::{BlindSum, BlindingFactor, Identifier, Keychain};
use libtx::Error;
use libtx::{aggsig, proof};
@ -251,7 +251,7 @@ mod test {
use util::RwLock;
use super::*;
use core::core::verifier_cache::{LruVerifierCache, VerifierCache};
use core::verifier_cache::{LruVerifierCache, VerifierCache};
use keychain::{ExtKeychain, ExtKeychainPath};
fn verifier_cache() -> Arc<RwLock<VerifierCache>> {

View file

@ -16,7 +16,7 @@
use failure::{Backtrace, Context, Fail};
use std::fmt::{self, Display};
use core::core::{committed, transaction};
use core::{committed, transaction};
use keychain;
use util::secp;

View file

@ -28,8 +28,8 @@ pub mod proof;
pub mod reward;
pub mod slate;
use core::consensus;
use core::core::Transaction;
use consensus;
use core::Transaction;
pub use libtx::error::{Error, ErrorKind};

View file

@ -16,10 +16,10 @@
//! reward.
use keychain::{Identifier, Keychain};
use core::consensus::reward;
use core::core::transaction::kernel_sig_msg;
use core::core::KernelFeatures;
use core::core::{Output, OutputFeatures, TxKernel};
use consensus::reward;
use core::transaction::kernel_sig_msg;
use core::KernelFeatures;
use core::{Output, OutputFeatures, TxKernel};
use libtx::error::Error;
use libtx::{aggsig, proof};
use util::static_secp_instance;

View file

@ -19,10 +19,10 @@ use rand::thread_rng;
use std::sync::Arc;
use uuid::Uuid;
use core::core::committed::Committed;
use core::core::transaction::kernel_sig_msg;
use core::core::verifier_cache::LruVerifierCache;
use core::core::{amount_to_hr_string, Transaction};
use core::committed::Committed;
use core::transaction::kernel_sig_msg;
use core::verifier_cache::LruVerifierCache;
use core::{amount_to_hr_string, Transaction};
use keychain::{BlindSum, BlindingFactor, Keychain};
use libtx::error::{Error, ErrorKind};
use libtx::{aggsig, build, tx_fee};

View file

@ -16,7 +16,6 @@ extern crate chrono;
extern crate grin_core;
extern crate grin_keychain as keychain;
extern crate grin_util as util;
extern crate grin_wallet as wallet;
use std::sync::Arc;
use std::time::Instant;
@ -34,9 +33,9 @@ use grin_core::core::verifier_cache::{LruVerifierCache, VerifierCache};
use grin_core::core::Committed;
use grin_core::core::{Block, BlockHeader, CompactBlock, KernelFeatures, OutputFeatures};
use grin_core::{global, ser};
use grin_core::libtx::build::{self, input, output, with_fee};
use keychain::{BlindingFactor, ExtKeychain, Keychain};
use util::secp;
use wallet::libtx::build::{self, input, output, with_fee};
fn verifier_cache() -> Arc<RwLock<VerifierCache>> {
Arc::new(RwLock::new(LruVerifierCache::new()))

View file

@ -17,14 +17,13 @@
extern crate grin_core;
extern crate grin_keychain as keychain;
extern crate grin_util as util;
extern crate grin_wallet as wallet;
use grin_core::core::block::{Block, BlockHeader};
use grin_core::core::Transaction;
use grin_core::pow::Difficulty;
use keychain::{Identifier, Keychain};
use wallet::libtx::build::{self, input, output, with_fee};
use wallet::libtx::reward;
use grin_core::libtx::build::{self, input, output, with_fee};
use grin_core::libtx::reward;
// utility producing a transaction with 2 inputs and a single outputs
pub fn tx2i1o() -> Transaction {

View file

@ -16,7 +16,6 @@
extern crate grin_core;
extern crate grin_keychain as keychain;
extern crate grin_util as util;
extern crate grin_wallet as wallet;
use std::sync::Arc;
use util::RwLock;
@ -29,12 +28,12 @@ use grin_core::core::block::Error::KernelLockHeight;
use grin_core::core::hash::{Hashed, ZERO_HASH};
use grin_core::core::verifier_cache::{LruVerifierCache, VerifierCache};
use grin_core::core::{aggregate, deaggregate, KernelFeatures, Output, Transaction};
use grin_core::libtx::build::{
self, initial_tx, input, output, with_excess, with_fee, with_lock_height,
};
use grin_core::ser;
use keychain::{BlindingFactor, ExtKeychain, Keychain};
use util::static_secp_instance;
use wallet::libtx::build::{
self, initial_tx, input, output, with_excess, with_fee, with_lock_height,
};
#[test]
fn simple_tx_ser() {

View file

@ -16,14 +16,13 @@
extern crate grin_core;
extern crate grin_keychain as keychain;
extern crate grin_util as util;
extern crate grin_wallet as wallet;
pub mod common;
use grin_core::core::{Output, OutputFeatures};
use grin_core::libtx::proof;
use grin_core::ser;
use keychain::{ExtKeychain, Keychain};
use wallet::libtx::proof;
#[test]
fn test_output_ser_deser() {

View file

@ -16,7 +16,6 @@ extern crate chrono;
extern crate grin_core;
extern crate grin_keychain as keychain;
extern crate grin_util as util;
extern crate grin_wallet as wallet;
use std::sync::Arc;
use util::RwLock;
@ -26,7 +25,7 @@ pub mod common;
use grin_core::core::verifier_cache::{LruVerifierCache, VerifierCache};
use grin_core::core::{Output, OutputFeatures};
use keychain::{ExtKeychain, Keychain};
use wallet::libtx::proof;
use grin_core::libtx::proof;
fn verifier_cache() -> Arc<RwLock<VerifierCache>> {
Arc::new(RwLock::new(LruVerifierCache::new()))

View file

@ -34,7 +34,7 @@ use core::core::{Block, BlockHeader, Transaction};
use core::pow::Difficulty;
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use core::libtx;
use common::*;

View file

@ -35,7 +35,7 @@ use core::core::hash::Hashed;
use core::core::verifier_cache::LruVerifierCache;
use core::pow::Difficulty;
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use core::libtx;
#[test]
fn test_transaction_pool_block_reconciliation() {

View file

@ -40,7 +40,7 @@ use chain::types::Tip;
use pool::*;
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use core::libtx;
use pool::types::*;
use pool::TransactionPool;

View file

@ -33,7 +33,7 @@ use core::core::verifier_cache::LruVerifierCache;
use core::core::{transaction, Block, BlockHeader};
use core::pow::Difficulty;
use keychain::{ExtKeychain, Keychain};
use wallet::libtx;
use core::libtx;
/// Test we can add some txs to the pool (both stempool and txpool).
#[test]

View file

@ -25,7 +25,7 @@ use util::RwLock;
use chain;
use common::types::Error;
use core::core::verifier_cache::VerifierCache;
use core::{consensus, core, ser};
use core::{consensus, core, libtx, ser};
use keychain::{ExtKeychain, Identifier, Keychain};
use pool;
use util;
@ -173,7 +173,7 @@ fn burn_reward(block_fees: BlockFees) -> Result<(core::Output, core::TxKernel, B
let keychain = ExtKeychain::from_random_seed().unwrap();
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
let (out, kernel) =
wallet::libtx::reward::output(&keychain, &key_id, block_fees.fees, block_fees.height)
libtx::reward::output(&keychain, &key_id, block_fees.fees, block_fees.height)
.unwrap();
Ok((out, kernel, block_fees))
}

View file

@ -19,7 +19,7 @@ use std::io::{Read, Write};
use serde_json as json;
use std::collections::HashMap;
use libtx::slate::Slate;
use core::libtx::slate::Slate;
use libwallet::{Error, ErrorKind};
use {WalletCommAdapter, WalletConfig};

View file

@ -18,7 +18,7 @@ use std::collections::HashMap;
use api;
use controller;
use libtx::slate::Slate;
use core::libtx::slate::Slate;
use libwallet::{Error, ErrorKind};
use {instantiate_wallet, WalletCommAdapter, WalletConfig};

View file

@ -22,7 +22,7 @@ pub use self::null::NullWalletCommAdapter;
use std::collections::HashMap;
use libtx::slate::Slate;
use core::libtx::slate::Slate;
use libwallet::Error;
use WalletConfig;

View file

@ -13,7 +13,7 @@
// limitations under the License.
/// Null Output 'plugin' implementation
use libtx::slate::Slate;
use core::libtx::slate::Slate;
use libwallet::Error;
use {WalletCommAdapter, WalletConfig};

View file

@ -24,7 +24,7 @@ use futures::future::{err, ok};
use futures::{Future, Stream};
use hyper::{Body, Request, Response, StatusCode};
use keychain::Keychain;
use libtx::slate::Slate;
use core::libtx::slate::Slate;
use libwallet::api::{APIForeign, APIOwner};
use libwallet::types::{
CbData, NodeClient, OutputData, SendTXArgs, TxLogEntry, WalletBackend, WalletInfo,

View file

@ -15,7 +15,7 @@
//! Implementation specific error types
use api;
use keychain;
use libtx;
use core::libtx;
use libwallet;
use std::fmt::{self, Display};

View file

@ -50,7 +50,6 @@ mod adapters;
pub mod controller;
pub mod display;
mod error;
pub mod libtx;
pub mod libwallet;
pub mod lmdb_wallet;
mod node_clients;

View file

@ -38,7 +38,7 @@ use core::core::hash::Hashed;
use core::core::Transaction;
use core::ser;
use keychain::{Identifier, Keychain};
use libtx::slate::Slate;
use core::libtx::slate::Slate;
use libwallet::internal::{keys, tx, updater};
use libwallet::types::{
AcctPathMapping, BlockFees, CbData, NodeClient, OutputData, TxLogEntry, TxWrapper,

View file

@ -22,7 +22,7 @@ use failure::{Backtrace, Context, Fail};
use core;
use core::core::transaction;
use keychain;
use libtx;
use core::libtx;
/// Error definition
#[derive(Debug, Fail)]
@ -257,7 +257,7 @@ impl From<keychain::Error> for Error {
}
impl From<libtx::Error> for Error {
fn from(error: libtx::Error) -> Error {
fn from(error: core::libtx::Error) -> Error {
Error {
inner: Context::new(ErrorKind::LibTX(error.kind())),
}

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! lower-level wallet functions which build upon libtx to perform wallet
//! lower-level wallet functions which build upon core::libtx to perform wallet
//! operations
#![deny(non_upper_case_globals)]

View file

@ -15,7 +15,7 @@
use core::global;
use keychain::{ExtKeychain, Identifier, Keychain};
use libtx::proof;
use core::libtx::proof;
use libwallet::internal::keys;
use libwallet::types::*;
use libwallet::Error;

View file

@ -15,7 +15,7 @@
//! Selection of inputs for building transactions
use keychain::{Identifier, Keychain};
use libtx::{build, slate::Slate, tx_fee};
use core::libtx::{build, slate::Slate, tx_fee};
use libwallet::error::{Error, ErrorKind};
use libwallet::internal::keys;
use libwallet::types::*;

View file

@ -19,7 +19,7 @@ use uuid::Uuid;
use core::ser;
use keychain::{Identifier, Keychain};
use libtx::slate::Slate;
use core::libtx::slate::Slate;
use libwallet::internal::{selection, updater};
use libwallet::types::{Context, NodeClient, TxLogEntryType, WalletBackend};
use libwallet::{Error, ErrorKind};
@ -234,7 +234,7 @@ where
#[cfg(test)]
mod test {
use keychain::{ExtKeychain, ExtKeychainPath, Keychain};
use libtx::build;
use core::libtx::build;
#[test]
// demonstrate that input.commitment == referenced output.commitment

View file

@ -23,7 +23,7 @@ use core::consensus::reward;
use core::core::{Output, TxKernel};
use core::{global, ser};
use keychain::{Identifier, Keychain};
use libtx::reward;
use core::libtx::reward;
use libwallet;
use libwallet::error::{Error, ErrorKind};
use libwallet::internal::keys;

View file

@ -31,7 +31,7 @@ use core::ser;
use keychain::{Identifier, Keychain};
use libtx::aggsig;
use core::libtx::aggsig;
use libwallet::error::{Error, ErrorKind};
use util;

View file

@ -42,7 +42,7 @@ use core::{pow, ser};
use keychain::Keychain;
use util::secp::pedersen;
use wallet::libtx::slate::Slate;
use core::libtx::slate::Slate;
use wallet::libwallet::types::*;
use wallet::{controller, libwallet, WalletCommAdapter, WalletConfig};

View file

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! libtx specific tests
//! core::libtx specific tests
extern crate grin_core as core;
extern crate grin_keychain as keychain;
extern crate grin_util as util;
@ -24,7 +24,7 @@ use core::core::transaction::kernel_sig_msg;
use keychain::{BlindSum, BlindingFactor, ExtKeychain, Keychain};
use util::secp;
use util::secp::key::{PublicKey, SecretKey};
use wallet::libtx::{aggsig, proof};
use core::libtx::{aggsig, proof};
use wallet::libwallet::types::Context;
use wallet::{EncryptedWalletSeed, WalletSeed};

View file

@ -35,7 +35,7 @@ use std::time::Duration;
use core::global;
use core::global::ChainTypes;
use keychain::ExtKeychain;
use wallet::libtx::slate::Slate;
use core::libtx::slate::Slate;
use wallet::{libwallet, FileWalletCommAdapter};
fn clean_output_dir(test_dir: &str) {

View file

@ -35,7 +35,7 @@ use std::time::Duration;
use core::global;
use core::global::ChainTypes;
use keychain::{ExtKeychain, Identifier, Keychain};
use wallet::libtx::slate::Slate;
use core::libtx::slate::Slate;
use wallet::libwallet;
use wallet::libwallet::types::AcctPathMapping;

View file

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! tests for transactions building within libtx
//! tests for transactions building within core::libtx
extern crate grin_chain as chain;
extern crate grin_core as core;
extern crate grin_keychain as keychain;
@ -35,7 +35,7 @@ use std::time::Duration;
use core::global;
use core::global::ChainTypes;
use keychain::ExtKeychain;
use wallet::libtx::slate::Slate;
use core::libtx::slate::Slate;
use wallet::libwallet;
use wallet::libwallet::types::OutputStatus;
@ -123,7 +123,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
let (_, wallet1_info) = api.retrieve_summary_info(true, 1)?;
let (refreshed, txs) = api.retrieve_txs(true, None, None)?;
assert!(refreshed);
let fee = wallet::libtx::tx_fee(
let fee = core::libtx::tx_fee(
wallet1_info.last_confirmed_height as usize - cm as usize,
2,
1,
@ -169,7 +169,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
"Wallet 1 Info Post Transaction, after {} blocks: {:?}",
wallet1_info.last_confirmed_height, wallet1_info
);
let fee = wallet::libtx::tx_fee(
let fee = core::libtx::tx_fee(
wallet1_info.last_confirmed_height as usize - 1 - cm as usize,
2,
1,