From e661499b4aff621c35e168f2bca6c314b42460ad Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Fri, 17 Jan 2025 13:44:26 +0100 Subject: [PATCH 1/2] return discount info from transaction --- src/rest.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rest.rs b/src/rest.rs index ca94afa6..be868774 100644 --- a/src/rest.rs +++ b/src/rest.rs @@ -127,6 +127,12 @@ struct TransactionValue { fee: u64, #[serde(skip_serializing_if = "Option::is_none")] status: Option, + + #[cfg(feature = "liquid")] + discount_vsize: usize, + + #[cfg(feature = "liquid")] + discount_weight: usize, } impl TransactionValue { @@ -170,6 +176,12 @@ impl TransactionValue { weight: weight as u64, fee, status: Some(TransactionStatus::from(blockid)), + + #[cfg(feature = "liquid")] + discount_vsize: tx.discount_vsize(), + + #[cfg(feature = "liquid")] + discount_weight: tx.discount_weight(), } } } From d1120e03fd093db5eaf30b35e37a9b1cdc8d24c1 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Fri, 17 Jan 2025 13:44:48 +0100 Subject: [PATCH 2/2] test discount info are present in liquid --- tests/rest.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/rest.rs b/tests/rest.rs index ce49feb7..f72b9c47 100644 --- a/tests/rest.rs +++ b/tests/rest.rs @@ -40,6 +40,11 @@ fn test_rest() -> Result<()> { vout["scriptpubkey_address"].as_str() == Some(&addr1.to_string()) && vout["value"].as_u64() == Some(119123000) })); + #[cfg(feature = "liquid")] + { + assert_eq!(res["discount_vsize"].as_u64().unwrap(), 228); + assert_eq!(res["discount_weight"].as_u64().unwrap(), 912); + } // Test GET /tx/:txid/status let res = get_json(&format!("/tx/{}/status", txid1_confirmed))?;