Client: allow tz1... as the source of a transfer

This is only useful when a 'remote signer' is available.
This commit is contained in:
Grégoire Henry 2018-05-26 13:41:51 +02:00
parent fb85568d98
commit da921a8f56
2 changed files with 33 additions and 17 deletions

View File

@ -141,6 +141,7 @@ let register_key cctxt ?(force=false) (public_key_hash, pk_uri, sk_uri) name =
return () return ()
let raw_get_key (cctxt : #Client_context.wallet) pkh = let raw_get_key (cctxt : #Client_context.wallet) pkh =
begin
Public_key_hash.rev_find cctxt pkh >>=? function Public_key_hash.rev_find cctxt pkh >>=? function
| None -> failwith "no keys for the source contract manager" | None -> failwith "no keys for the source contract manager"
| Some n -> | Some n ->
@ -158,6 +159,21 @@ let raw_get_key (cctxt : #Client_context.wallet) pkh =
pk_uri pk_uri
end >>= fun pk -> end >>= fun pk ->
return (n, pk, sk_uri) return (n, pk, sk_uri)
end >>= function
| (Ok (_, None, None) | Error _) as initial_result -> begin
begin
(* try to lookup for a remote key *)
find_signer_for_key ~scheme:"remote" >>=? fun signer ->
let module Signer = (val signer : SIGNER) in
let path = Signature.Public_key_hash.to_b58check pkh in
let uri = Uri.make ~scheme:Signer.scheme ~path () in
Signer.public_key uri >>=? fun pk ->
return (path, Some pk, Some uri)
end >>= function
| Error _ -> Lwt.return initial_result
| Ok _ as success -> Lwt.return success
end
| Ok _ as success -> Lwt.return success
let get_key cctxt pkh = let get_key cctxt pkh =
raw_get_key cctxt pkh >>=? function raw_get_key cctxt pkh >>=? function

View File

@ -222,7 +222,7 @@ let commands () =
@@ tez_param @@ tez_param
~name: "qty" ~desc: "amount taken from source" ~name: "qty" ~desc: "amount taken from source"
@@ prefix "from" @@ prefix "from"
@@ ContractAlias.alias_param @@ ContractAlias.destination_param
~name: "src" ~desc: "name of the source contract" ~name: "src" ~desc: "name of the source contract"
@@ prefix "to" @@ prefix "to"
@@ ContractAlias.destination_param @@ ContractAlias.destination_param