keetanetwork-block 0.2.0

Block structure and operations for Keetanetwork blockchain
docs.rs failed to build keetanetwork-block-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: keetanetwork-block-0.1.0

Keetanetwork Block

Block structure, operations, signing and validation for the Keetanetwork blockchain.

Example

use keetanetwork_account::{Account, Accountable, GenericAccount, KeyED25519, KeyPairType, Keyable};
use keetanetwork_block::{AccountRef, Block, BlockBuilder, Operation, Receive};
use keetanetwork_crypto::hash::Hashable;
use keetanetwork_crypto::prelude::IntoSecret;

let seed = [7u8; 32].into_secret();
let account = Account::<KeyED25519>::try_from(Accountable::KeyAndType(
    Keyable::Seed((seed, 0)),
    KeyPairType::ED25519,
))?;
let token = account.generate_identifier(KeyPairType::TOKEN, None, 0)?;
let account = AccountRef::from(GenericAccount::Ed25519(account));

let unsigned = BlockBuilder::default()
    .with_network(0u8)
    .with_account(account.clone())
    .as_opening()
    .with_operation(Receive {
        amount: 10u64.into(),
        token: token.into(),
        from: account.clone(),
        exact: false,
        forward: None,
    })
    .build()?;

let block = unsigned.sign()?;
let decoded = Block::try_from(block.to_bytes())?;
assert_eq!(decoded.hash(), block.hash());
# Ok::<(), keetanetwork_block::BlockError>(())