diff --git a/src/bin_client/test/test_basic.sh b/src/bin_client/test/test_basic.sh index 72f5a6a70..e10d3beda 100755 --- a/src/bin_client/test/test_basic.sh +++ b/src/bin_client/test/test_basic.sh @@ -67,6 +67,7 @@ $client transfer 10 from bootstrap1 to hardlimit -arg "Unit" $client originate free account free_account for $key1 $client get delegate for free_account +$client register key $key2 as delegate $client set delegate for free_account to $key2 $client get delegate for free_account diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index f72c10f35..a66f65a89 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -212,6 +212,13 @@ let set_delegate cctxt block ~fee contract ~src_pk ~manager_sk opt_delegate = delegate_contract cctxt block ~source:contract ~src_pk ~manager_sk ~fee opt_delegate +let register_as_delegate cctxt block ~fee ~manager_sk src_pk = + let source = Ed25519.Public_key.hash src_pk in + delegate_contract + cctxt block + ~source:(Contract.implicit_contract source) ~src_pk ~manager_sk ~fee + (Some source) + let source_to_keys (wallet : #Proto_alpha.full) block source = get_manager wallet block source >>=? fun (_src_name, _src_pkh, src_pk, src_sk) -> return (src_pk, src_sk) diff --git a/src/proto_alpha/lib_client/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli index fdc270166..2947102b1 100644 --- a/src/proto_alpha/lib_client/client_proto_context.mli +++ b/src/proto_alpha/lib_client/client_proto_context.mli @@ -44,6 +44,13 @@ val set_delegate : public_key_hash option -> Operation_list_hash.elt tzresult Lwt.t +val register_as_delegate: + #Proto_alpha.full -> + Block_services.block -> + fee:Tez.tez -> + manager_sk:Client_keys.sk_locator -> + public_key -> Operation_list_hash.elt tzresult Lwt.t + val operation_submitted_message : #Client_context.printer -> Operation_hash.t -> diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 7b575288a..5262912a7 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -242,6 +242,20 @@ let commands () = operation_submitted_message cctxt oph end; + command ~group ~desc: "Register the public key hash as a delegate." + (args1 fee_arg) + (prefixes [ "register" ; "key" ] + @@ Public_key_hash.alias_param + ~name: "mgr" ~desc: "the delegate key" + @@ prefixes [ "as" ; "delegate" ] + @@ stop) + begin fun fee (_, src_pkh) cctxt -> + Client_keys.get_key cctxt src_pkh >>=? fun (_, src_pk, src_sk) -> + register_as_delegate cctxt + ~fee cctxt#block ~manager_sk:src_sk src_pk >>=? fun oph -> + operation_submitted_message cctxt oph + end; + command ~group:alphanet ~desc: "Open a new FREE account (Alphanet only)." (args1 force_switch) (prefixes [ "originate" ; "free" ; "account" ]