chore(chain): Standardise KeychainTxOutIndex return types

The previous commit b9c5b9d08b040faf6c6b2d9b3745918031555b72 added
IndexSpk. This goes further and adds `Indexed` and `KeychainIndexed`
type alises (IndexSpk is Indexed<ScriptBuf>) and attempts to standardize
the structure of return types more generally.
This commit is contained in:
LLFourn
2024-06-07 12:29:58 +10:00
committed by 志宇
parent bce070b1d6
commit 101a09a97f
12 changed files with 103 additions and 90 deletions

View File

@@ -265,9 +265,6 @@ where
.expect("Must exist");
changeset.append(change_changeset);
// Clone to drop the immutable reference.
let change_script = change_script.into();
let change_plan = bdk_tmp_plan::plan_satisfaction(
&graph
.index
@@ -481,8 +478,8 @@ where
local_chain::ChangeSet::default(),
indexed_tx_graph::ChangeSet::from(index_changeset),
)))?;
let addr =
Address::from_script(spk, network).context("failed to derive address")?;
let addr = Address::from_script(spk.as_script(), network)
.context("failed to derive address")?;
println!("[address @ {}] {}", spk_i, addr);
Ok(())
}

View File

@@ -228,7 +228,7 @@ fn main() -> anyhow::Result<()> {
let all_spks = graph
.index
.revealed_spks(..)
.map(|(index, spk)| (index.to_owned(), spk.to_owned()))
.map(|(index, spk)| (index, spk.to_owned()))
.collect::<Vec<_>>();
request = request.chain_spks(all_spks.into_iter().map(|((k, spk_i), spk)| {
eprint!("Scanning {}: {}", k, spk_i);
@@ -239,7 +239,7 @@ fn main() -> anyhow::Result<()> {
let unused_spks = graph
.index
.unused_spks()
.map(|(index, spk)| (index.to_owned(), spk.to_owned()))
.map(|(index, spk)| (index, spk.to_owned()))
.collect::<Vec<_>>();
request =
request.chain_spks(unused_spks.into_iter().map(move |((k, spk_i), spk)| {

View File

@@ -245,7 +245,7 @@ fn main() -> anyhow::Result<()> {
let all_spks = graph
.index
.revealed_spks(..)
.map(|((k, i), spk)| (k.to_owned(), *i, spk.to_owned()))
.map(|((k, i), spk)| (k, i, spk.to_owned()))
.collect::<Vec<_>>();
request = request.chain_spks(all_spks.into_iter().map(|(k, i, spk)| {
eprint!("scanning {}:{}", k, i);
@@ -258,7 +258,7 @@ fn main() -> anyhow::Result<()> {
let unused_spks = graph
.index
.unused_spks()
.map(|(index, spk)| (index.to_owned(), spk.to_owned()))
.map(|(index, spk)| (index, spk.to_owned()))
.collect::<Vec<_>>();
request =
request.chain_spks(unused_spks.into_iter().map(move |((k, i), spk)| {