refactor: use tuple struct for psbt type
This commit is contained in:
parent
d0514f678e
commit
00a8e1ba8b
@ -186,20 +186,16 @@ impl From<&Transaction> for BdkTransaction {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Psbt {
|
||||
pub(crate) inner: Mutex<BdkPsbt>,
|
||||
}
|
||||
pub struct Psbt(pub(crate) Mutex<BdkPsbt>);
|
||||
|
||||
impl Psbt {
|
||||
pub(crate) fn new(psbt_base64: String) -> Result<Self, PsbtParseError> {
|
||||
let psbt: BdkPsbt = BdkPsbt::from_str(&psbt_base64)?;
|
||||
Ok(Psbt {
|
||||
inner: Mutex::new(psbt),
|
||||
})
|
||||
Ok(Psbt(Mutex::new(psbt)))
|
||||
}
|
||||
|
||||
pub(crate) fn serialize(&self) -> String {
|
||||
let psbt = self.inner.lock().unwrap().clone();
|
||||
let psbt = self.0.lock().unwrap().clone();
|
||||
psbt.to_string()
|
||||
}
|
||||
|
||||
@ -210,7 +206,7 @@ impl Psbt {
|
||||
// }
|
||||
|
||||
pub(crate) fn extract_tx(&self) -> Result<Arc<Transaction>, ExtractTxError> {
|
||||
let tx: BdkTransaction = self.inner.lock().unwrap().clone().extract_tx()?;
|
||||
let tx: BdkTransaction = self.0.lock().unwrap().clone().extract_tx()?;
|
||||
let transaction: Transaction = tx.into();
|
||||
Ok(Arc::new(transaction))
|
||||
}
|
||||
@ -254,9 +250,7 @@ impl Psbt {
|
||||
|
||||
impl From<BdkPsbt> for Psbt {
|
||||
fn from(psbt: BdkPsbt) -> Self {
|
||||
Psbt {
|
||||
inner: Mutex::new(psbt),
|
||||
}
|
||||
Psbt(Mutex::new(psbt))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ impl Wallet {
|
||||
psbt: Arc<Psbt>,
|
||||
// sign_options: Option<SignOptions>,
|
||||
) -> Result<bool, SignerError> {
|
||||
let mut psbt = psbt.inner.lock().unwrap();
|
||||
let mut psbt = psbt.0.lock().unwrap();
|
||||
self.get_wallet()
|
||||
.sign(&mut psbt, SignOptions::default())
|
||||
.map_err(SignerError::from)
|
||||
|
Loading…
x
Reference in New Issue
Block a user