File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -996,6 +996,24 @@ pub trait ChangeDestinationSource {
996
996
fn get_change_destination_script < ' a > ( & self ) -> AsyncGetChangeDestinationScriptResult < ' a , ScriptBuf > ;
997
997
}
998
998
999
+
1000
+ /// A synchronous helper trait that describes an on-chain wallet capable of returning a (change) destination script.
1001
+ pub trait ChangeDestinationSourceSync {
1002
+ /// This method should return a different value each time it is called, to avoid linking
1003
+ /// on-chain funds controlled to the same user.
1004
+ fn get_change_destination_script ( & self ) -> Result < ScriptBuf , ( ) > ;
1005
+ }
1006
+
1007
+ /// A wrapper around [`ChangeDestinationSource`] to allow for async calls.
1008
+ pub struct ChangeDestinationSourceSyncWrapper < T > ( T ) where T : ChangeDestinationSourceSync ;
1009
+
1010
+ impl < T : ChangeDestinationSourceSync > ChangeDestinationSource for ChangeDestinationSourceSyncWrapper < T > {
1011
+ fn get_change_destination_script < ' a > ( & self ) -> AsyncGetChangeDestinationScriptResult < ' a , ScriptBuf > {
1012
+ let script = self . 0 . get_change_destination_script ( ) ;
1013
+ Box :: pin ( async move { script } )
1014
+ }
1015
+ }
1016
+
999
1017
mod sealed {
1000
1018
use bitcoin:: secp256k1:: { Scalar , SecretKey } ;
1001
1019
You can’t perform that action at this time.
0 commit comments