diff --git a/src/gd_con.erl b/src/gd_con.erl index eef0a57..ae773b4 100644 --- a/src/gd_con.erl +++ b/src/gd_con.erl @@ -183,6 +183,11 @@ sign_binary(Request) -> gd_server:cast(?MODULE, {sign_binary, Request}). +-spec sign_binary(ID, Message) -> Result + when ID :: binary(), + Message :: binary(), + Result :: {ok, Sig :: binary()} | {error, bad_key}. + sign_binary(ID, Message) -> gd_server:call(?MODULE, {sign_binary, ID, Message}). @@ -461,6 +466,9 @@ handle_call(chain_id, _, State) -> handle_call({sign_call, ChainID, PubKey, TX}, _, State) -> Response = do_sign_call(State, ChainID, PubKey, TX), {reply, Response, State}; +handle_call({sign_binary, ID, Message}, _, State) -> + Response = do_sign_binary(ID, Message, State), + {reply, Response, State}; handle_call({open_wallet, Path, Phrase}, _, State) -> {Response, NewState} = do_open_wallet(Path, Phrase, State), {reply, Response, NewState}; @@ -522,9 +530,6 @@ handle_cast({sign_mess, Request}, State) -> handle_cast({sign_binary, Request}, State) -> ok = do_sign_binary(Request, State), {noreply, State}; -handle_cast({sign_binary, ID, Message}, State) -> - ok = do_sign_binary(ID, Message, State), - {noreply, State}; handle_cast({sign_tx, Request}, State) -> ok = do_sign_tx(Request, State), {noreply, State}; diff --git a/src/gd_n_recvr.erl b/src/gd_n_recvr.erl index 1e16c92..57f1701 100644 --- a/src/gd_n_recvr.erl +++ b/src/gd_n_recvr.erl @@ -103,11 +103,14 @@ handshake(State = #s{socket = Socket}, Ref, From) -> ok = active_once(State), receive {tcp, Socket, <<"GajuExpress 1 RECVR:", Challenge/binary>>} -> + tell(info, "Got challenge ~p", [Challenge]), case is_sus(Challenge) of false -> + tell(info, "Not sus"), From ! {Ref, {ok, Challenge}}, authenticate(State); true -> + tell(info, "Sus"), From ! {Ref, {error, "Challenge was sus."}}, retire(State, normal) end; @@ -150,6 +153,7 @@ decode_challenge(TS, Rand) -> authenticate(State = #s{socket = Socket}) -> receive {Ref, From, {response, Sig}} -> + tell(info, "Got sig: ~p", [Sig]), ok = send(Socket, Sig), await_auth(State, Ref, From); nope -> diff --git a/src/gd_v_express.erl b/src/gd_v_express.erl index 55f9e25..732d175 100644 --- a/src/gd_v_express.erl +++ b/src/gd_v_express.erl @@ -348,7 +348,7 @@ do_check2(State = #s{recvr = PID}) -> State#s{recvr = none} end. -challenge(State = #s{recvr = PID, keys = KeyP}, Challenge) -> +challenge(State = #s{recvr = PID, keys = #w{wx = KeyP}}, Challenge) -> case wxChoice:getStringSelection(KeyP) of "" -> ok = gd_n_recvr:stop(PID), @@ -416,7 +416,7 @@ do_retire(PID, Info, State = #s{rider = PID}) -> ok = tell(info, "Rider retired with: ~p", [Info]), State#s{rider = none}; do_retire(PID, Info, State = #s{recvr = PID}) -> - ok = tell(info, "Rider retired with: ~p", [Info]), + ok = tell(info, "Recvr retired with: ~p", [Info]), State#s{recvr = none}; do_retire(PID, Info, State) -> ok = tell(info, "~p retired with: ~p", [PID, Info]),