Skip to content

Commit

Permalink
Merge pull request mimblewimble#17 from antiochp/plain_kernels
Browse files Browse the repository at this point in the history
default to using a Plain kernel with no lock_height
  • Loading branch information
antiochp authored Mar 19, 2019
2 parents db01596 + e3b5e5b commit 64772e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ target
grin.log
wallet.seed
test_output
wallet_data
wallet/db
wallet*
.idea/
18 changes: 18 additions & 0 deletions controller/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
})?;

Expand Down
6 changes: 5 additions & 1 deletion libwallet/src/internal/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 64772e6

Please sign in to comment.