diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index ddaab519fa..cc82497293 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -1069,7 +1069,7 @@ impl, I: 'static> Currency for Pallet where // may not even be a provider. let allow_death = existence_requirement == ExistenceRequirement::AllowDeath; let allow_death = allow_death && !system::Pallet::::is_provider_required(transactor); - ensure!(allow_death || from_account.free >= ed, Error::::KeepAlive); + ensure!(allow_death || from_account.total() >= ed, Error::::KeepAlive); Ok(()) } diff --git a/substrate/frame/balances/src/tests.rs b/substrate/frame/balances/src/tests.rs index ef5823b3bc..776cda140e 100644 --- a/substrate/frame/balances/src/tests.rs +++ b/substrate/frame/balances/src/tests.rs @@ -961,5 +961,18 @@ macro_rules! decl_tests { assert_storage_noop!(assert_eq!(Balances::slash(&1337, 42).1, 42)); }); } + + #[test] + fn transfer_keep_alive_all_free_succeed() { + <$ext_builder>::default() + .existential_deposit(100) + .build() + .execute_with(|| { + assert_ok!(Balances::set_balance(Origin::root(), 1, 100, 100)); + assert_ok!(Balances::transfer_keep_alive(Some(1).into(), 2, 100)); + assert_eq!(Balances::total_balance(&1), 100); + assert_eq!(Balances::total_balance(&2), 100); + }); + } } }