diff --git a/doc/API.md b/doc/API.md index 0d472b4a..887cfc4d 100644 --- a/doc/API.md +++ b/doc/API.md @@ -94,6 +94,7 @@ This command does not take any parameter for now. | Field | Type | Description | | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------ | +| `address` | string | Address containing the script pubkey of the coin | | `amount` | int | Value of the TxO in satoshis. | | `outpoint` | string | Transaction id and output index of this coin. | | `block_height` | int or null | Block height the transaction was confirmed at, or `null`. | diff --git a/src/commands/mod.rs b/src/commands/mod.rs index d4298db4..4c264a77 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -310,7 +310,11 @@ impl DaemonControl { height: spend_block.map(|b| b.height), }); let block_height = block_info.map(|b| b.height); + let address = self + .derived_desc(&coin) + .address(self.config.bitcoin_config.network); ListCoinsEntry { + address, amount, outpoint, block_height, @@ -856,7 +860,7 @@ pub struct LCSpendInfo { pub height: Option, } -#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct ListCoinsEntry { #[serde( serialize_with = "ser_amount", @@ -864,6 +868,11 @@ pub struct ListCoinsEntry { )] pub amount: bitcoin::Amount, pub outpoint: bitcoin::OutPoint, + #[serde( + serialize_with = "ser_to_string", + deserialize_with = "deser_addr_assume_checked" + )] + pub address: bitcoin::Address, pub block_height: Option, /// Information about the transaction spending this coin. pub spend_info: Option,