default to using a Plain kernel with no lock_height

when constructing txs via the wallet
This commit is contained in:
antiochp 2019-03-13 12:19:56 +00:00
parent db015960a9
commit e3b5e5b1de
No known key found for this signature in database
GPG key ID: 49CBDBCE8AB061C1
3 changed files with 24 additions and 3 deletions

3
.gitignore vendored
View file

@ -10,6 +10,5 @@ target
grin.log
wallet.seed
test_output
wallet_data
wallet/db
wallet*
.idea/

View file

@ -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(())
})?;

View file

@ -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)
}