nut09.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //! NUT-09: Restore signatures
  2. //!
  3. //! <https://github.com/cashubtc/nuts/blob/main/09.md>
  4. use serde::{Deserialize, Serialize};
  5. use super::nut00::{BlindSignature, BlindedMessage};
  6. /// Restore Request [NUT-09]
  7. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
  8. #[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))]
  9. pub struct RestoreRequest {
  10. /// Outputs
  11. pub outputs: Vec<BlindedMessage>,
  12. }
  13. /// Restore Response [NUT-09]
  14. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
  15. #[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))]
  16. pub struct RestoreResponse {
  17. /// Outputs
  18. pub outputs: Vec<BlindedMessage>,
  19. /// Signatures
  20. pub signatures: Vec<BlindSignature>,
  21. /// Promises
  22. // Temp compatibility with cashu-ts
  23. pub promises: Option<Vec<BlindSignature>>,
  24. }
  25. mod test {
  26. #[test]
  27. fn restore_response() {
  28. use super::*;
  29. let rs = r#"{"outputs":[{"B_":"0204bbffa045f28ec836117a29ea0a00d77f1d692e38cf94f72a5145bfda6d8f41","amount":0,"id":"00ffd48b8f5ecf80", "witness":null},{"B_":"025f0615ccba96f810582a6885ffdb04bd57c96dbc590f5aa560447b31258988d7","amount":0,"id":"00ffd48b8f5ecf80"}],"signatures":[{"C_":"02e9701b804dc05a5294b5a580b428237a27c7ee1690a0177868016799b1761c81","amount":8,"dleq":null,"id":"00ffd48b8f5ecf80"},{"C_":"031246ee046519b15648f1b8d8ffcb8e537409c84724e148c8d6800b2e62deb795","amount":2,"dleq":null,"id":"00ffd48b8f5ecf80"}]}"#;
  30. let res: RestoreResponse = serde_json::from_str(rs).unwrap();
  31. println!("{:?}", res);
  32. }
  33. }