From 382b22b93b997d944ea91a4fd328abcdee502b47 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Wed, 27 Jan 2016 17:25:19 +0100 Subject: [PATCH] Fixing suicide with self-refund to be consistent with CPP. --- src/externalities.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/externalities.rs b/src/externalities.rs index f1b8c1958..6a874330c 100644 --- a/src/externalities.rs +++ b/src/externalities.rs @@ -215,8 +215,13 @@ impl<'a> Ext for Externalities<'a> { fn suicide(&mut self, refund_address: &Address) { let address = self.origin_info.address.clone(); let balance = self.balance(&address); - trace!("Suiciding {} -> {} (xfer: {})", address, refund_address, balance); - self.state.transfer_balance(&address, refund_address, &balance); + if &address == refund_address { + // TODO [todr] To be consisted with CPP client we set balance to 0 in that case. + self.state.sub_balance(&address, &balance); + } else { + trace!("Suiciding {} -> {} (xfer: {})", address, refund_address, balance); + self.state.transfer_balance(&address, refund_address, &balance); + } self.substate.suicides.insert(address); }