diff --git a/src/network.rs b/src/network.rs index c988ff1..858c623 100644 --- a/src/network.rs +++ b/src/network.rs @@ -4,9 +4,8 @@ use anyhow::Result; use rand::{thread_rng, RngCore}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use sp_client::bitcoin::consensus::serialize; use sp_client::bitcoin::hex::DisplayHex; -use sp_client::bitcoin::{OutPoint, Transaction}; +use sp_client::bitcoin::OutPoint; use tsify::Tsify; use crate::error::AnkError; @@ -74,7 +73,7 @@ impl AnkFlag { #[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Tsify)] #[tsify(into_wasm_abi, from_wasm_abi)] pub struct CommitMessage { - pub init_tx: String, // Can be tx or txid of the first transaction of the chain, which is maybe not ideal + pub process_id: OutPoint, pub pcd_commitment: Value, // map of field <=> hash of the clear value pub roles: HashMap, // Can be hashed and compared with the value above pub validation_tokens: Vec, @@ -82,33 +81,15 @@ pub struct CommitMessage { } impl CommitMessage { - /// Create a new commitment message for the first transaction of the chain - /// init_tx must be the hex string of the transaction - /// validation_tokens must be empty - pub fn new_first_commitment( - transaction: Transaction, - pcd_commitment: Value, - roles: HashMap, - ) -> Self { - Self { - init_tx: serialize(&transaction).to_lower_hex_string(), - pcd_commitment, - roles, - validation_tokens: vec![], - error: None, - } - } - - /// Create a new commitment message for an update transaction - /// init_tx must be the hex string of the txid of the first commitment transaction + /// Create a new commitment message for a creation/update transaction /// validation_tokens must be empty pub fn new_update_commitment( - init_tx: OutPoint, + process_id: OutPoint, pcd_commitment: Value, roles: HashMap, ) -> Self { Self { - init_tx: init_tx.to_string(), + process_id, pcd_commitment, roles, validation_tokens: vec![],