From 81eab0f33769c063b7d2a9139d37c9155e8fbcac Mon Sep 17 00:00:00 2001 From: Boyu Yang Date: Mon, 18 Mar 2024 15:43:45 +0800 Subject: [PATCH] chore: a construct method for default change builder --- src/transaction/builder/mod.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/transaction/builder/mod.rs b/src/transaction/builder/mod.rs index 8e942a06..f6edd0f6 100644 --- a/src/transaction/builder/mod.rs +++ b/src/transaction/builder/mod.rs @@ -40,7 +40,7 @@ pub trait ChangeBuilder { fn finalize(&self, tx: TransactionBuilder) -> TransactionView; } -/// A simple implementation for the chhange output builder trait. +/// A simple implementation for the change output builder trait. pub struct DefaultChangeBuilder<'a> { configuration: &'a TransactionBuilderConfiguration, change_lock: Script, @@ -48,6 +48,20 @@ pub struct DefaultChangeBuilder<'a> { } impl<'a> DefaultChangeBuilder<'a> { + /// Creates a new instance of `DefaultChangeBuilder`. + pub fn new( + configuration: &'a TransactionBuilderConfiguration, + change_lock: Script, + inputs: Vec, + ) -> Self { + Self { + configuration, + change_lock, + inputs, + } + } + + /// Returns the change output and its data. pub fn get_change(&self) -> (CellOutput, packed::Bytes) { let change_output = CellOutput::new_builder() .lock(self.change_lock.clone())