Add new_request
This commit is contained in:
parent
13957e3e1f
commit
b6ffebf6c0
13
src/prd.rs
13
src/prd.rs
@ -27,6 +27,7 @@ pub enum PrdType {
|
|||||||
Response, // Validate (or disagree) with a prd update
|
Response, // Validate (or disagree) with a prd update
|
||||||
Confirm, // Confirm we received an update
|
Confirm, // Confirm we received an update
|
||||||
TxProposal, // Send a psbt asking for recipient signature
|
TxProposal, // Send a psbt asking for recipient signature
|
||||||
|
Request // asks for the prd update for some state,
|
||||||
}
|
}
|
||||||
|
|
||||||
sha256t_hash_newtype! {
|
sha256t_hash_newtype! {
|
||||||
@ -51,7 +52,7 @@ impl AnkPrdHash {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Tsify)]
|
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize, Tsify)]
|
||||||
#[tsify(into_wasm_abi, from_wasm_abi)]
|
#[tsify(into_wasm_abi, from_wasm_abi)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub struct Prd {
|
pub struct Prd {
|
||||||
@ -138,6 +139,16 @@ impl Prd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_request(root_commitment: OutPoint, sender: Member, state_ids: Vec<[u8; 32]>) -> Self {
|
||||||
|
Self {
|
||||||
|
prd_type: PrdType::Request,
|
||||||
|
root_commitment: root_commitment.to_string(),
|
||||||
|
sender: serde_json::to_string(&sender).unwrap(),
|
||||||
|
payload: serde_json::to_string(&state_ids).unwrap(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn extract_from_message(plain: &[u8], local_address: SilentPaymentAddress) -> Result<Self> {
|
pub fn extract_from_message(plain: &[u8], local_address: SilentPaymentAddress) -> Result<Self> {
|
||||||
let prd: Prd = serde_json::from_slice(plain)?;
|
let prd: Prd = serde_json::from_slice(plain)?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user