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

@@ -12,7 +12,7 @@
#[cfg(feature = "miniscript")]
mod txout_index;
use bitcoin::Amount;
use bitcoin::{Amount, ScriptBuf};
#[cfg(feature = "miniscript")]
pub use txout_index::*;
@@ -49,6 +49,11 @@ impl Balance {
}
}
/// A tuple of keychain index and corresponding [`ScriptBuf`].
pub type Indexed<T> = (u32, T);
/// A tuple of keychain, index and the [`ScriptBuf`] derived at that location.
pub type KeychainIndexed<K, T> = ((K, u32), T);
impl core::fmt::Display for Balance {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(