@@ -33,7 +33,9 @@ use witnet_data_structures::{
3333 fee:: Fee ,
3434 get_environment,
3535 proto:: ProtobufConvert ,
36- transaction:: { DRTransaction , StakeTransaction , Transaction , VTTransaction } ,
36+ transaction:: {
37+ DRTransaction , StakeTransaction , Transaction , UnstakeTransaction , VTTransaction ,
38+ } ,
3739 transaction_factory:: NodeBalance ,
3840 types:: SequentialId ,
3941 utxo_pool:: { UtxoInfo , UtxoSelectionStrategy } ,
@@ -45,8 +47,9 @@ use witnet_node::actors::{
4547 AddrType , GetBlockChainParams , GetTransactionOutput , PeersResult , QueryStakesArgument ,
4648 } ,
4749 messages:: {
48- AuthorizeStake , BuildDrt , BuildStakeParams , BuildStakeResponse , BuildVtt , GetBalanceTarget ,
49- GetReputationResult , MagicEither , SignalingInfo , StakeAuthorization ,
50+ AuthorizeStake , BuildDrt , BuildStakeParams , BuildStakeResponse , BuildUnstakeParams ,
51+ BuildVtt , GetBalanceTarget , GetReputationResult , MagicEither , SignalingInfo ,
52+ StakeAuthorization ,
5053 } ,
5154} ;
5255use witnet_rad:: types:: RadonTypes ;
@@ -1052,6 +1055,42 @@ pub fn authorize_st(addr: SocketAddr, withdrawer: Option<String>) -> Result<(),
10521055 Ok ( ( ) )
10531056}
10541057
1058+ #[ allow( clippy:: too_many_arguments) ]
1059+ pub fn send_ut (
1060+ addr : SocketAddr ,
1061+ value : u64 ,
1062+ operator : MagicEither < String , PublicKeyHash > ,
1063+ dry_run : bool ,
1064+ ) -> Result < ( ) , failure:: Error > {
1065+ let mut stream = start_client ( addr) ?;
1066+ let mut id = SequentialId :: initialize ( 1u8 ) ;
1067+
1068+ let build_unstake_params = BuildUnstakeParams {
1069+ operator,
1070+ value,
1071+ dry_run,
1072+ } ;
1073+
1074+ // Finally ask the node to create the transaction.
1075+ let ( _, ( request, response) ) : ( UnstakeTransaction , _ ) = issue_method (
1076+ "unstake" ,
1077+ Some ( build_unstake_params) ,
1078+ & mut stream,
1079+ id. next ( ) ,
1080+ ) ?;
1081+
1082+ // On dry run mode, print the request, otherwise, print the response.
1083+ // This is kept like this strictly for backwards compatibility.
1084+ // TODO: wouldn't it be better to always print the response or both?
1085+ if dry_run {
1086+ println ! ( "{}" , request) ;
1087+ } else {
1088+ println ! ( "{}" , response) ;
1089+ }
1090+
1091+ Ok ( ( ) )
1092+ }
1093+
10551094pub fn master_key_export (
10561095 addr : SocketAddr ,
10571096 write_to_path : Option < & Path > ,
0 commit comments