-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d83a3f1
commit 8307170
Showing
36 changed files
with
985 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use crate::core::types::Block; | ||
use crate::core::types::Address; | ||
use crate::core::consensus::ConsensusEngine; | ||
|
||
pub fn get_current_validator(consensus: &mut ConsensusEngine) -> Option<Address> { | ||
crate::core::consensus::select_next_validator(consensus) | ||
} | ||
|
||
pub fn get_latest_block(consensus: &mut ConsensusEngine) -> Option<Block> { | ||
consensus.chain.last().cloned() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub mod wallet; | ||
pub mod transaction; | ||
pub mod blockchain; | ||
|
||
pub use wallet::create_wallet; | ||
pub use transaction::{build_transaction, finalize_transaction, submit_transaction}; | ||
pub use blockchain::{get_current_validator, get_latest_block}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use ed25519_dalek::{SigningKey, VerifyingKey}; | ||
use rand::rngs::OsRng; | ||
use hex; | ||
use crate::core::types::Address; | ||
|
||
pub fn create_wallet() -> (SigningKey, VerifyingKey, Address) { | ||
let signing_key = SigningKey::generate(&mut OsRng); | ||
let verifying_key = VerifyingKey::from(&signing_key); | ||
let address = hex::encode(verifying_key.to_bytes()); | ||
|
||
(signing_key, verifying_key, address) | ||
} |
Oops, something went wrong.