From e53da8c1b6ba0fb6b069e480fb5bc832df694043 Mon Sep 17 00:00:00 2001 From: Eloc <42568538+elocremarc@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:22:55 -0700 Subject: [PATCH 1/3] Recursive inscription add address --- src/api.rs | 1 + src/subcommand/server.rs | 17 +++++++++++++++++ tests/server.rs | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index 45200115e6..604caf5999 100644 --- a/src/api.rs +++ b/src/api.rs @@ -126,6 +126,7 @@ pub struct InscriptionRecursive { pub satpoint: SatPoint, pub timestamp: i64, pub value: Option, + pub address: Option, } #[derive(Debug, PartialEq, Serialize, Deserialize)] diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 46054c1445..e31476cd0c 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -1067,6 +1067,16 @@ impl Server { ) }; + let address = output + .as_ref() + .and_then(|output| { + server_config + .chain + .address_from_script(&output.script_pubkey) + .ok() + }) + .map(|address| address.to_string()); + Ok( Json(api::InscriptionRecursive { charms: Charm::charms(entry.charms), @@ -1082,6 +1092,7 @@ impl Server { sat: entry.sat, satpoint, timestamp: timestamp(entry.timestamp.into()).timestamp(), + address, }) .into_response(), ) @@ -6777,6 +6788,7 @@ next }, timestamp: 2, value: Some(50 * COIN_VALUE), + address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string()) } ); @@ -6806,6 +6818,7 @@ next }, timestamp: 2, value: Some(50 * COIN_VALUE), + address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string()) } ); @@ -6828,6 +6841,7 @@ next }, timestamp: 2, value: Some(50 * COIN_VALUE), + address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string()) } ); } @@ -7013,6 +7027,7 @@ next }, timestamp: 2, value: Some(50 * COIN_VALUE), + address: None } ); } @@ -7067,6 +7082,7 @@ next }, timestamp: 2, value: Some(50 * COIN_VALUE), + address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string()) } ); @@ -7111,6 +7127,7 @@ next }, timestamp: 2, value: Some(50 * COIN_VALUE), + address: None } ); } diff --git a/tests/server.rs b/tests/server.rs index 788bb8be70..f8f62af7bf 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -494,9 +494,12 @@ fn recursive_inscription_endpoint() { "application/json" ); - let inscription_recursive_json: api::InscriptionRecursive = + let mut inscription_recursive_json: api::InscriptionRecursive = serde_json::from_str(&response.text().unwrap()).unwrap(); + assert_regex_match!(inscription_recursive_json.address.unwrap(), r"bc1p.*"); + inscription_recursive_json.address = None; + pretty_assert_eq!( inscription_recursive_json, api::InscriptionRecursive { @@ -516,6 +519,7 @@ fn recursive_inscription_endpoint() { }, timestamp: 2, value: Some(10000), + address: None, } ) } From 07abd4af9a7ccac4f846c76edced0df8c5d2bb50 Mon Sep 17 00:00:00 2001 From: Eloc <42568538+elocremarc@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:21:35 -0700 Subject: [PATCH 2/3] update recursion docs --- docs/src/inscriptions/recursion.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/inscriptions/recursion.md b/docs/src/inscriptions/recursion.md index 77b2ef2fb0..bde18fc6e7 100644 --- a/docs/src/inscriptions/recursion.md +++ b/docs/src/inscriptions/recursion.md @@ -192,7 +192,8 @@ percentile in sats/vB. "sat": null, "satpoint": "3bd72a7ef68776c9429961e43043ff65efa7fb2d8bb407386a9e3b19f149bc36:0:0", "timestamp": 1708312562, - "value": 10000 + "value": 10000, + "address": "bc1pz4kvfpurqc2hwgrq0nwtfve2lfxvdpfcdpzc6ujchyr3ztj6gd9sfr6ayf" } ``` From c38448509f353fa7b4a30594ed00b5664d293a1e Mon Sep 17 00:00:00 2001 From: raphjaph Date: Tue, 3 Sep 2024 13:35:41 +0300 Subject: [PATCH 3/3] Amend --- src/subcommand/server.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 477eb6ddbd..5a48afd79b 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -1059,15 +1059,13 @@ impl Server { ) }; - let address = output - .as_ref() - .and_then(|output| { - server_config - .chain - .address_from_script(&output.script_pubkey) - .ok() - }) - .map(|address| address.to_string()); + let address = output.as_ref().and_then(|output| { + server_config + .chain + .address_from_script(&output.script_pubkey) + .ok() + .map(|address| address.to_string()) + }); Ok( Json(api::InscriptionRecursive {