feat: add sign method on wallet type
This commit is contained in:
		
							parent
							
								
									787152e0b4
								
							
						
					
					
						commit
						26352edfbe
					
				| @ -92,6 +92,9 @@ interface Wallet { | ||||
| 
 | ||||
|   [Throws=BdkError] | ||||
|   void apply_update(Update update); | ||||
| 
 | ||||
|   [Throws=BdkError] | ||||
|   boolean sign(PartiallySignedTransaction psbt); | ||||
| }; | ||||
| 
 | ||||
| interface Update {}; | ||||
|  | ||||
| @ -7,7 +7,7 @@ use std::collections::HashSet; | ||||
| use bdk::bitcoin::blockdata::script::ScriptBuf as BdkScriptBuf; | ||||
| use bdk::bitcoin::OutPoint as BdkOutPoint; | ||||
| use bdk::wallet::Update as BdkUpdate; | ||||
| use bdk::Wallet as BdkWallet; | ||||
| use bdk::{SignOptions, Wallet as BdkWallet}; | ||||
| use bdk::{Error as BdkError, FeeRate}; | ||||
| 
 | ||||
| use bdk::wallet::tx_builder::ChangeSpendPolicy; | ||||
| @ -73,6 +73,26 @@ impl Wallet { | ||||
|         self.get_wallet().is_mine(&script.0) | ||||
|         // self.get_wallet().is_mine(script.0.clone().as_script())
 | ||||
|     } | ||||
| 
 | ||||
|     /// Sign a transaction with all the wallet's signers, in the order specified by every signer's
 | ||||
|     /// [`SignerOrdering`]. This function returns the `Result` type with an encapsulated `bool` that
 | ||||
|     /// has the value true if the PSBT was finalized, or false otherwise.
 | ||||
|     ///
 | ||||
|     /// The [`SignOptions`] can be used to tweak the behavior of the software signers, and the way
 | ||||
|     /// the transaction is finalized at the end. Note that it can't be guaranteed that *every*
 | ||||
|     /// signers will follow the options, but the "software signers" (WIF keys and `xprv`) defined
 | ||||
|     /// in this library will.
 | ||||
|     pub(crate) fn sign( | ||||
|         &self, | ||||
|         psbt: Arc<PartiallySignedTransaction>, | ||||
|         // sign_options: Option<SignOptions>,
 | ||||
|     ) -> Result<bool, BdkError> { | ||||
|         let mut psbt = psbt.inner.lock().unwrap(); | ||||
|         self.get_wallet().sign( | ||||
|             &mut psbt, | ||||
|             SignOptions::default(), | ||||
|         ).map_err(|e| BdkError::Generic(e.to_string())) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| pub struct Update(pub(crate) BdkUpdate); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user