From 44d8c7093a9717a4dcc618b83dbc1814cac16342 Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Mon, 21 Aug 2023 16:02:43 +0100 Subject: [PATCH] chore: implement dump_private_key for light client Signed-off-by: Gregory Hill --- bitcoin/src/light/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bitcoin/src/light/mod.rs b/bitcoin/src/light/mod.rs index e4a906649..66f20231e 100644 --- a/bitcoin/src/light/mod.rs +++ b/bitcoin/src/light/mod.rs @@ -172,8 +172,14 @@ impl BitcoinCoreApi for BitcoinLight { Ok(self.private_key.public_key(&self.secp_ctx)) } - fn dump_private_key(&self, _: &Address) -> Result { - Err(Error::InvalidAddress.into()) + fn dump_private_key(&self, address: &Address) -> Result { + self.wallet + .key_store + .read() + .map_err(Into::::into)? + .get(address) + .ok_or(Error::NoPrivateKey.into()) + .cloned() } fn import_private_key(&self, _private_key: &PrivateKey, _is_derivation_key: bool) -> Result<(), BitcoinError> {