Introduce `ChangeDestinationSource` trait
authorElias Rohrer <dev@tnull.de>
Tue, 16 Apr 2024 09:12:43 +0000 (11:12 +0200)
committerElias Rohrer <dev@tnull.de>
Thu, 18 Apr 2024 14:09:04 +0000 (16:09 +0200)
.. which users should implement on their on-chain wallet to allow us to
retrieve a new change destination script.

lightning/src/sign/mod.rs

index 1459151de1c043964d80d77ca4403fa92f6211aa..9b5efee4b9695cc10a3df1cef99e4d4328dc05b1 100644 (file)
@@ -904,6 +904,17 @@ pub trait SignerProvider {
        fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()>;
 }
 
+/// A helper trait that describes an on-chain wallet capable of returning a (change) destination
+/// script.
+pub trait ChangeDestinationSource {
+       /// Returns a script pubkey which can be used as a change destination for
+       /// [`OutputSpender::spend_spendable_outputs`].
+       ///
+       /// This method should return a different value each time it is called, to avoid linking
+       /// on-chain funds controlled to the same user.
+       fn get_change_destination_script(&self) -> Result<ScriptBuf, ()>;
+}
+
 /// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory.
 ///
 /// This implementation performs no policy checks and is insufficient by itself as