Skip to content

Commit

Permalink
Merge c1e93ab into e79b77d
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-da committed May 28, 2021
2 parents e79b77d + c1e93ab commit a14a6c6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/dbc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use std::collections::BTreeMap;
use crate::{
DbcContent, DbcContentHash, DbcTransaction, Error, Hash, KeyCache, PublicKey, Result, Signature,
};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Dbc {
pub content: DbcContent,
pub transaction: DbcTransaction,
Expand Down
3 changes: 2 additions & 1 deletion src/dbc_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ use std::collections::BTreeSet;
use tiny_keccak::{Hasher, Sha3};

use crate::{DbcContentHash, Hash};
use serde::{Deserialize, Serialize};

/// The spent identifier of the outputs created from this input
/// Note these are hashes and not identifiers as the Dbc is not addressable on the network.
/// i.e. a Dbc can be stored anywhere, even offline.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct DbcTransaction {
pub inputs: BTreeSet<DbcContentHash>,
pub outputs: BTreeSet<DbcContentHash>,
Expand Down
5 changes: 3 additions & 2 deletions src/key_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use ed25519::{Keypair, PublicKey as EdPublicKey, Signature as EdSignature, Signe
use tiny_keccak::{Hasher, Sha3};

use crate::{Error, Hash, Result};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct PublicKey(pub(crate) EdPublicKey);

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Signature(pub(crate) EdSignature);

impl PartialEq for PublicKey {
Expand Down
11 changes: 6 additions & 5 deletions src/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// input is vaid
// Outputs <= input value

use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};

use crate::{
Expand All @@ -23,8 +24,8 @@ use crate::{
pub type InputSignatures = BTreeMap<DbcContentHash, (PublicKey, Signature)>;

#[derive(Debug, Default)]
struct SpendBook {
transactions: BTreeMap<DbcContentHash, DbcTransaction>,
pub struct SpendBook {
pub transactions: BTreeMap<DbcContentHash, DbcTransaction>,
}

impl SpendBook {
Expand All @@ -37,7 +38,7 @@ impl SpendBook {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MintTransaction {
pub inputs: HashSet<Dbc>,
pub outputs: HashSet<DbcContent>,
Expand Down Expand Up @@ -109,7 +110,7 @@ impl MintTransaction {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MintRequest {
pub transaction: MintTransaction,
// Signatures from the owners of each input, signing `self.transaction.blinded().hash()`
Expand All @@ -119,7 +120,7 @@ pub struct MintRequest {
#[derive(Debug)]
pub struct Mint {
pub(crate) key_mgr: KeyManager,
spendbook: SpendBook,
pub spendbook: SpendBook,
}

impl Mint {
Expand Down

0 comments on commit a14a6c6

Please sign in to comment.