agent-pay 0.1.0

L402 + DID-signed invoices: agent-to-agent Lightning payments (Rust port of @p-vbordei/agent-pay)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use agent_pay::{canonical_json, jcs_hash};
use serde_json::json;

#[test]
fn canonical_json_sorts_keys_lexicographically() {
    let a = canonical_json(&json!({"b": 1, "a": 2})).unwrap();
    let b = canonical_json(&json!({"a": 2, "b": 1})).unwrap();
    assert_eq!(std::str::from_utf8(&a).unwrap(), r#"{"a":2,"b":1}"#);
    assert_eq!(a, b);
}

#[test]
fn jcs_hash_returns_32_byte_sha256() {
    let h = jcs_hash(&json!({"x": 1})).unwrap();
    assert_eq!(h.len(), 32);
}