@@ -501,10 +501,14 @@ where
501501 }
502502
503503 /// Generate an address in the internal keychain (WIP-0001).
504- pub fn gen_internal_address ( & self , label : Option < String > ) -> Result < Arc < model:: Address > > {
504+ pub fn gen_internal_address (
505+ & self ,
506+ label : Option < String > ,
507+ preview : bool ,
508+ ) -> Result < Arc < model:: Address > > {
505509 let mut state = self . state . write ( ) ?;
506510
507- self . _gen_internal_address ( & mut state, label)
511+ self . _gen_internal_address ( & mut state, label, preview )
508512 }
509513
510514 /// Return a list of the generated external addresses that.
@@ -1082,6 +1086,7 @@ where
10821086 outputs,
10831087 utxo_strategy,
10841088 selected_utxos,
1089+ preview,
10851090 } : types:: VttParams ,
10861091 ) -> Result < ( model:: ExtendedTransaction , AbsoluteFee ) > {
10871092 let mut state = self . state . write ( ) ?;
@@ -1095,6 +1100,7 @@ where
10951100 fee,
10961101 & utxo_strategy,
10971102 selected_utxos,
1103+ preview,
10981104 ) ?;
10991105
11001106 let pointers_as_inputs = inputs
@@ -1118,14 +1124,18 @@ where
11181124
11191125 pub fn create_data_req (
11201126 & self ,
1121- types:: DataReqParams { fee, request } : types:: DataReqParams ,
1127+ types:: DataReqParams {
1128+ fee,
1129+ request,
1130+ preview,
1131+ } : types:: DataReqParams ,
11221132 ) -> Result < ( model:: ExtendedTransaction , AbsoluteFee ) > {
11231133 let mut state = self . state . write ( ) ?;
11241134 let TransactionComponents {
11251135 fee,
11261136 inputs,
11271137 outputs,
1128- } = self . create_dr_transaction_components ( & mut state, request. clone ( ) , fee) ?;
1138+ } = self . create_dr_transaction_components ( & mut state, request. clone ( ) , fee, preview ) ?;
11291139
11301140 let pointers_as_inputs = inputs
11311141 . pointers
@@ -1190,6 +1200,7 @@ where
11901200 fee : Fee ,
11911201 utxo_strategy : & UtxoSelectionStrategy ,
11921202 selected_utxos : HashSet < model:: OutPtr > ,
1203+ preview : bool ,
11931204 ) -> Result < TransactionComponents > {
11941205 let timestamp = u64:: try_from ( get_timestamp ( ) ) . unwrap ( ) ;
11951206
@@ -1203,6 +1214,7 @@ where
12031214 utxo_strategy,
12041215 self . params . max_vt_weight ,
12051216 selected_utxos,
1217+ preview,
12061218 )
12071219 }
12081220
@@ -1211,6 +1223,7 @@ where
12111223 state : & mut State ,
12121224 request : DataRequestOutput ,
12131225 fee : Fee ,
1226+ preview : bool ,
12141227 ) -> Result < TransactionComponents > {
12151228 let utxo_strategy = UtxoSelectionStrategy :: Random { from : None } ;
12161229 let timestamp = u64:: try_from ( get_timestamp ( ) ) . unwrap ( ) ;
@@ -1225,6 +1238,7 @@ where
12251238 & utxo_strategy,
12261239 self . params . max_dr_weight ,
12271240 HashSet :: default ( ) ,
1241+ preview,
12281242 )
12291243 }
12301244
@@ -1233,14 +1247,15 @@ where
12331247 & self ,
12341248 state : & mut State ,
12351249 force_input : Option < Input > ,
1250+ preview : bool ,
12361251 ) -> Result < PublicKeyHash > {
12371252 let pkh = if let Some ( input) = force_input {
12381253 let forced = input. output_pointer ( ) ;
12391254 let key_balance = state. utxo_set . get ( & forced. into ( ) ) . unwrap ( ) ;
12401255
12411256 key_balance. pkh
12421257 } else {
1243- self . _gen_internal_address ( state, None ) ?. pkh
1258+ self . _gen_internal_address ( state, None , preview ) ?. pkh
12441259 } ;
12451260
12461261 Ok ( pkh)
@@ -1263,6 +1278,7 @@ where
12631278 utxo_strategy : & UtxoSelectionStrategy ,
12641279 max_weight : u32 ,
12651280 selected_utxos : HashSet < model:: OutPtr > ,
1281+ preview : bool ,
12661282 ) -> Result < TransactionComponents > {
12671283 let empty_hashset = HashSet :: default ( ) ;
12681284 let unconfirmed_transactions = if self . params . use_unconfirmed_utxos {
@@ -1298,6 +1314,7 @@ where
12981314 let change_pkh = self . calculate_change_address (
12991315 state,
13001316 dr_output. and_then ( |_| inputs. pointers . get ( 0 ) . cloned ( ) . map ( Input :: new) ) ,
1317+ preview,
13011318 ) ?;
13021319
13031320 let mut outputs = outputs;
@@ -1318,14 +1335,15 @@ where
13181335 & self ,
13191336 state : & mut State ,
13201337 label : Option < String > ,
1338+ preview : bool ,
13211339 ) -> Result < Arc < model:: Address > > {
13221340 let keychain = constants:: INTERNAL_KEYCHAIN ;
13231341 let account = state. account ;
13241342 let index = state. next_internal_index ;
13251343 let parent_key = & state. keychains [ keychain as usize ] ;
13261344
13271345 let ( address, next_index) =
1328- self . derive_and_persist_address ( label, parent_key, account, keychain, index, true ) ?;
1346+ self . derive_and_persist_address ( label, parent_key, account, keychain, index, !preview ) ?;
13291347
13301348 state. next_internal_index = next_index;
13311349
@@ -1569,7 +1587,7 @@ where
15691587 state. transient_external_addresses . remove ( & addr. pkh ) ;
15701588 }
15711589 for _ in state. next_internal_index ..new_internal_index {
1572- let addr = self . _gen_internal_address ( & mut state, None ) ?;
1590+ let addr = self . _gen_internal_address ( & mut state, None , false ) ?;
15731591 state. transient_internal_addresses . remove ( & addr. pkh ) ;
15741592 }
15751593
0 commit comments