@@ -435,6 +435,8 @@ pub struct TransactionBuilder {
435435 utxos : Vec < InputBuilderResult > ,
436436 collateral_return : Option < TransactionOutput > ,
437437 reference_inputs : Option < Vec < TransactionUnspentOutput > > ,
438+ donation : Option < Coin > ,
439+ current_treasury_value : Option < Coin > ,
438440}
439441
440442impl TransactionBuilder {
@@ -911,6 +913,14 @@ impl TransactionBuilder {
911913 self . fee = Some ( fee)
912914 }
913915
916+ pub fn set_donation ( & mut self , donation : Coin ) {
917+ self . donation = Some ( donation)
918+ }
919+
920+ pub fn set_current_treasury_value ( & mut self , current_treasury_value : Coin ) {
921+ self . current_treasury_value = Some ( current_treasury_value)
922+ }
923+
914924 pub fn set_ttl ( & mut self , ttl : Slot ) {
915925 self . ttl = Some ( ttl)
916926 }
@@ -1125,6 +1135,8 @@ impl TransactionBuilder {
11251135 utxos : Vec :: new ( ) ,
11261136 collateral_return : None ,
11271137 reference_inputs : None ,
1138+ donation : None ,
1139+ current_treasury_value : None ,
11281140 }
11291141 }
11301142
@@ -1243,12 +1255,16 @@ impl TransactionBuilder {
12431255 . map_err ( Into :: into)
12441256 }
12451257
1246- /// Return explicit output plus implicit output plus burn (does not consider fee directly)
1258+ /// Return explicit output plus implicit output plus burn/donation (does not consider fee directly)
12471259 pub fn get_total_output ( & self ) -> Result < Value , TxBuilderError > {
12481260 let ( _, burn_value) = self . get_mint_as_values ( ) ;
12491261 self . get_explicit_output ( ) ?
12501262 . checked_add ( & Value :: from ( self . get_deposit ( ) ?) )
12511263 . and_then ( |x| x. checked_add ( & burn_value) )
1264+ . and_then ( |x| match self . donation {
1265+ Some ( donation) => x. checked_add ( & Value :: from ( donation) ) ,
1266+ None => Ok ( x) ,
1267+ } )
12521268 . map_err ( Into :: into)
12531269 }
12541270
@@ -1405,8 +1421,8 @@ impl TransactionBuilder {
14051421 . proposals
14061422 . as_ref ( )
14071423 . map ( |proposals| proposals. clone ( ) . into ( ) ) ,
1408- current_treasury_value : None ,
1409- donation : None ,
1424+ current_treasury_value : self . current_treasury_value ,
1425+ donation : self . donation ,
14101426 encodings : None ,
14111427 } ;
14121428
0 commit comments