DRY up transaction signing

Cleanup the big mess I copy-pasted myself into.
This commit is contained in:
Greg Fitzgerald
2018-03-06 16:34:14 -07:00
parent b98e04dc56
commit f09952f3d7
10 changed files with 109 additions and 247 deletions

View File

@@ -4,8 +4,8 @@
use log::{Entry, Sha256Hash};
use event::Event;
use transaction::{sign_transaction_data, Transaction};
use signature::{get_pubkey, PublicKey, Signature};
use transaction::Transaction;
use signature::{PublicKey, Signature};
use genesis::Genesis;
use historian::{reserve_signature, Historian};
use ring::signature::Ed25519KeyPair;
@@ -137,16 +137,8 @@ impl Accountant {
keypair: &Ed25519KeyPair,
to: PublicKey,
) -> Result<Signature> {
let from = get_pubkey(keypair);
let last_id = self.last_id;
let sig = sign_transaction_data(&n, keypair, &to, &last_id);
let tr = Transaction {
from,
to,
asset: n,
last_id,
sig,
};
let tr = Transaction::new(keypair, to, n, self.last_id);
let sig = tr.sig;
self.process_transaction(tr).map(|_| sig)
}