diff --git a/.gitignore b/.gitignore index 728c195b5..e11f667cd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,5 @@ target grin.log wallet.seed test_output -wallet_data -wallet/db +wallet* .idea/ diff --git a/controller/tests/transaction.rs b/controller/tests/transaction.rs index 95b176340..2171404b6 100644 --- a/controller/tests/transaction.rs +++ b/controller/tests/transaction.rs @@ -18,6 +18,7 @@ extern crate grin_wallet_controller as wallet; extern crate grin_wallet_impls as impls; extern crate grin_wallet_libwallet as libwallet; +use self::core::core::transaction; use self::core::global; use self::core::global::ChainTypes; use self::keychain::ExtKeychain; @@ -106,9 +107,26 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> { true, // select all outputs None, None, )?; + + // Check we are creating a tx with the expected lock_height of 0. + // We will check this produces a Plain kernel later. + assert_eq!(0, slate.lock_height); + slate = client1.send_tx_slate_direct("wallet2", &slate_i)?; sender_api.tx_lock_outputs(&slate)?; sender_api.finalize_tx(&mut slate)?; + + // Check we have a single kernel and that it is a Plain kernel (no lock_height). + assert_eq!(slate.tx.kernels().len(), 1); + assert_eq!( + slate.tx.kernels().first().map(|k| k.lock_height).unwrap(), + 0 + ); + assert_eq!( + slate.tx.kernels().first().map(|k| k.features).unwrap(), + transaction::KernelFeatures::Plain + ); + Ok(()) })?; diff --git a/libwallet/src/internal/tx.rs b/libwallet/src/internal/tx.rs index 8af3682d3..ae95a6758 100644 --- a/libwallet/src/internal/tx.rs +++ b/libwallet/src/internal/tx.rs @@ -38,7 +38,11 @@ where let mut slate = Slate::blank(num_participants); slate.amount = amount; slate.height = current_height; - slate.lock_height = current_height; + + // Set the lock_height explicitly to 0 here. + // This will generate a Plain kernel (rather than a HeightLocked kernel). + slate.lock_height = 0; + Ok(slate) }