WIP
This commit is contained in:
+8
-3
@@ -183,6 +183,11 @@ sign_binary(Request) ->
|
|||||||
gd_server:cast(?MODULE, {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) ->
|
sign_binary(ID, Message) ->
|
||||||
gd_server:call(?MODULE, {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) ->
|
handle_call({sign_call, ChainID, PubKey, TX}, _, State) ->
|
||||||
Response = do_sign_call(State, ChainID, PubKey, TX),
|
Response = do_sign_call(State, ChainID, PubKey, TX),
|
||||||
{reply, Response, State};
|
{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) ->
|
handle_call({open_wallet, Path, Phrase}, _, State) ->
|
||||||
{Response, NewState} = do_open_wallet(Path, Phrase, State),
|
{Response, NewState} = do_open_wallet(Path, Phrase, State),
|
||||||
{reply, Response, NewState};
|
{reply, Response, NewState};
|
||||||
@@ -522,9 +530,6 @@ handle_cast({sign_mess, Request}, State) ->
|
|||||||
handle_cast({sign_binary, Request}, State) ->
|
handle_cast({sign_binary, Request}, State) ->
|
||||||
ok = do_sign_binary(Request, State),
|
ok = do_sign_binary(Request, State),
|
||||||
{noreply, 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) ->
|
handle_cast({sign_tx, Request}, State) ->
|
||||||
ok = do_sign_tx(Request, State),
|
ok = do_sign_tx(Request, State),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|||||||
@@ -103,11 +103,14 @@ handshake(State = #s{socket = Socket}, Ref, From) ->
|
|||||||
ok = active_once(State),
|
ok = active_once(State),
|
||||||
receive
|
receive
|
||||||
{tcp, Socket, <<"GajuExpress 1 RECVR:", Challenge/binary>>} ->
|
{tcp, Socket, <<"GajuExpress 1 RECVR:", Challenge/binary>>} ->
|
||||||
|
tell(info, "Got challenge ~p", [Challenge]),
|
||||||
case is_sus(Challenge) of
|
case is_sus(Challenge) of
|
||||||
false ->
|
false ->
|
||||||
|
tell(info, "Not sus"),
|
||||||
From ! {Ref, {ok, Challenge}},
|
From ! {Ref, {ok, Challenge}},
|
||||||
authenticate(State);
|
authenticate(State);
|
||||||
true ->
|
true ->
|
||||||
|
tell(info, "Sus"),
|
||||||
From ! {Ref, {error, "Challenge was sus."}},
|
From ! {Ref, {error, "Challenge was sus."}},
|
||||||
retire(State, normal)
|
retire(State, normal)
|
||||||
end;
|
end;
|
||||||
@@ -150,6 +153,7 @@ decode_challenge(TS, Rand) ->
|
|||||||
authenticate(State = #s{socket = Socket}) ->
|
authenticate(State = #s{socket = Socket}) ->
|
||||||
receive
|
receive
|
||||||
{Ref, From, {response, Sig}} ->
|
{Ref, From, {response, Sig}} ->
|
||||||
|
tell(info, "Got sig: ~p", [Sig]),
|
||||||
ok = send(Socket, Sig),
|
ok = send(Socket, Sig),
|
||||||
await_auth(State, Ref, From);
|
await_auth(State, Ref, From);
|
||||||
nope ->
|
nope ->
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ do_check2(State = #s{recvr = PID}) ->
|
|||||||
State#s{recvr = none}
|
State#s{recvr = none}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
challenge(State = #s{recvr = PID, keys = KeyP}, Challenge) ->
|
challenge(State = #s{recvr = PID, keys = #w{wx = KeyP}}, Challenge) ->
|
||||||
case wxChoice:getStringSelection(KeyP) of
|
case wxChoice:getStringSelection(KeyP) of
|
||||||
"" ->
|
"" ->
|
||||||
ok = gd_n_recvr:stop(PID),
|
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]),
|
ok = tell(info, "Rider retired with: ~p", [Info]),
|
||||||
State#s{rider = none};
|
State#s{rider = none};
|
||||||
do_retire(PID, Info, State = #s{recvr = PID}) ->
|
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};
|
State#s{recvr = none};
|
||||||
do_retire(PID, Info, State) ->
|
do_retire(PID, Info, State) ->
|
||||||
ok = tell(info, "~p retired with: ~p", [PID, Info]),
|
ok = tell(info, "~p retired with: ~p", [PID, Info]),
|
||||||
|
|||||||
Reference in New Issue
Block a user