@@ -33,7 +33,9 @@ use witnet_data_structures::{
33
33
fee:: Fee ,
34
34
get_environment,
35
35
proto:: ProtobufConvert ,
36
- transaction:: { DRTransaction , StakeTransaction , Transaction , VTTransaction } ,
36
+ transaction:: {
37
+ DRTransaction , StakeTransaction , Transaction , UnstakeTransaction , VTTransaction ,
38
+ } ,
37
39
transaction_factory:: NodeBalance ,
38
40
types:: SequentialId ,
39
41
utxo_pool:: { UtxoInfo , UtxoSelectionStrategy } ,
@@ -45,8 +47,9 @@ use witnet_node::actors::{
45
47
AddrType , GetBlockChainParams , GetTransactionOutput , PeersResult , QueryStakesArgument ,
46
48
} ,
47
49
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 ,
50
53
} ,
51
54
} ;
52
55
use witnet_rad:: types:: RadonTypes ;
@@ -1052,6 +1055,42 @@ pub fn authorize_st(addr: SocketAddr, withdrawer: Option<String>) -> Result<(),
1052
1055
Ok ( ( ) )
1053
1056
}
1054
1057
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
+
1055
1094
pub fn master_key_export (
1056
1095
addr : SocketAddr ,
1057
1096
write_to_path : Option < & Path > ,
0 commit comments