Add seed to transfering transaction
@@ -76,11 +76,12 @@ message! {
struct TxTransfer {
const TYPE = SERVICE_ID;
const ID = TX_TRANSFER_ID;
- const SIZE = 72;
+ const SIZE = 80;
field from: &PublicKey [00 => 32]
field to: &PublicKey [32 => 64]
field amount: u64 [64 => 72]
+ field seed: u64 [72 => 80]
}
}
@@ -95,6 +96,7 @@ impl Transaction for TxCreateWallet {
let mut schema = CurrencySchema { view };
if let None = schema.wallet(self.pub_key()) {
let wallet = Wallet::new(self.pub_key(), self.name(), 0);
+ println!("Create the wallet: {:?}", wallet);
schema.wallets().put(self.pub_key(), wallet)
}
}
@@ -109,6 +111,7 @@ impl Transaction for TxIssue {
let mut schema = CurrencySchema { view };
if let Some(mut wallet) = schema.wallet(self.pub_key()) {
wallet.increase(self.amount());
+ println!("Add funds to wallet: {:?}", wallet);
schema.wallets().put(self.pub_key(), wallet)
}
}
@@ -117,7 +120,7 @@ impl Transaction for TxIssue {
impl Transaction for TxTransfer {
fn verify(&self) -> bool {
- self.verify_signature(self.from()) && (*self.from() != *self.to())
+ (*self.from() != *self.to()) && self.verify_signature(self.from())
}
fn execute(&self, view: &mut Fork) {
@@ -129,7 +132,7 @@ impl Transaction for TxTransfer {
if sender.balance() >= amount {
sender.decrease(amount);
receiver.increase(amount);
- println!("{:?} => {:?}", sender, receiver);
+ println!("Transfer between wallets: {:?} => {:?}", sender, receiver);
let mut wallets = schema.wallets();
wallets.put(self.from(), sender);
wallets.put(self.to(), receiver);
