File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -996,6 +996,24 @@ pub trait ChangeDestinationSource {
996996 fn get_change_destination_script < ' a > ( & self ) -> AsyncGetChangeDestinationScriptResult < ' a , ScriptBuf > ;
997997}
998998
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+
9991017mod sealed {
10001018 use bitcoin:: secp256k1:: { Scalar , SecretKey } ;
10011019
You can’t perform that action at this time.
0 commit comments