Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add address feild to /r/inscription/:id #3891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/src/inscriptions/recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ percentile in sats/vB.
"sat": null,
"satpoint": "3bd72a7ef68776c9429961e43043ff65efa7fb2d8bb407386a9e3b19f149bc36:0:0",
"timestamp": 1708312562,
"value": 10000
"value": 10000,
"address": "bc1pz4kvfpurqc2hwgrq0nwtfve2lfxvdpfcdpzc6ujchyr3ztj6gd9sfr6ayf"
}
```

Expand Down
1 change: 1 addition & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub struct InscriptionRecursive {
pub satpoint: SatPoint,
pub timestamp: i64,
pub value: Option<u64>,
pub address: Option<String>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
Expand Down
15 changes: 15 additions & 0 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,14 @@ 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),
Expand All @@ -1074,6 +1082,7 @@ impl Server {
sat: entry.sat,
satpoint,
timestamp: timestamp(entry.timestamp.into()).timestamp(),
address,
})
.into_response(),
)
Expand Down Expand Up @@ -6695,6 +6704,7 @@ next
},
timestamp: 2,
value: Some(50 * COIN_VALUE),
address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string())
}
);

Expand Down Expand Up @@ -6724,6 +6734,7 @@ next
},
timestamp: 2,
value: Some(50 * COIN_VALUE),
address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string())
}
);

Expand All @@ -6746,6 +6757,7 @@ next
},
timestamp: 2,
value: Some(50 * COIN_VALUE),
address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string())
}
);
}
Expand Down Expand Up @@ -6931,6 +6943,7 @@ next
},
timestamp: 2,
value: Some(50 * COIN_VALUE),
address: None
}
);
}
Expand Down Expand Up @@ -6985,6 +6998,7 @@ next
},
timestamp: 2,
value: Some(50 * COIN_VALUE),
address: Some("bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202".to_string())
}
);

Expand Down Expand Up @@ -7029,6 +7043,7 @@ next
},
timestamp: 2,
value: Some(50 * COIN_VALUE),
address: None
}
);
}
Expand Down
6 changes: 5 additions & 1 deletion tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -516,6 +519,7 @@ fn recursive_inscription_endpoint() {
},
timestamp: 2,
value: Some(10000),
address: None,
}
)
}
Expand Down
Loading