Compare commits
7 Commits
6a1c8ecf62
...
07628a71b3
| Author | SHA1 | Date | |
|---|---|---|---|
| 07628a71b3 | |||
| 363dfaf271 | |||
| 25550cca32 | |||
| c452604f4b | |||
| 4446357437 | |||
| d8b8fee232 | |||
| b4ea4bdf10 |
@ -3,7 +3,7 @@
|
|||||||
{registered,[]},
|
{registered,[]},
|
||||||
{included_applications,[]},
|
{included_applications,[]},
|
||||||
{applications,[stdlib,kernel,sasl,ssl]},
|
{applications,[stdlib,kernel,sasl,ssl]},
|
||||||
{vsn,"0.7.0"},
|
{vsn,"0.8.0"},
|
||||||
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,
|
{modules,[gajudesk,gd_con,gd_grids,gd_gui,gd_jt,
|
||||||
gd_sophia_editor,gd_sup,gd_v,gd_v_devman,gd_v_netman,
|
gd_sophia_editor,gd_sup,gd_v,gd_v_devman,gd_v_netman,
|
||||||
gd_v_wallman]},
|
gd_v_wallman]},
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gajudesk).
|
-module(gajudesk).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-behavior(application).
|
-behavior(application).
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_con).
|
-module(gd_con).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@ -14,7 +14,8 @@
|
|||||||
selected/1, network/0,
|
selected/1, network/0,
|
||||||
password/2,
|
password/2,
|
||||||
refresh/0,
|
refresh/0,
|
||||||
nonce/1, spend/1, chain/1, grids/1, sign_mess/1, sign_tx/1, sign_call/3, dry_run/2,
|
nonce/1, spend/1, chain/1, grids/1,
|
||||||
|
sign_mess/1, sign_binary/1, sign_tx/1, sign_call/3, dry_run/2,
|
||||||
deploy/3,
|
deploy/3,
|
||||||
make_key/6, recover_key/1, mnemonic/1, rename_key/2, drop_key/1, list_keys/0,
|
make_key/6, recover_key/1, mnemonic/1, rename_key/2, drop_key/1, list_keys/0,
|
||||||
add_node/1, set_sole_node/1]).
|
add_node/1, set_sole_node/1]).
|
||||||
@ -172,6 +173,13 @@ sign_mess(Request) ->
|
|||||||
gen_server:cast(?MODULE, {sign_mess, Request}).
|
gen_server:cast(?MODULE, {sign_mess, Request}).
|
||||||
|
|
||||||
|
|
||||||
|
-spec sign_binary(Request) -> ok
|
||||||
|
when Request :: map().
|
||||||
|
|
||||||
|
sign_binary(Request) ->
|
||||||
|
gen_server:cast(?MODULE, {sign_binary, Request}).
|
||||||
|
|
||||||
|
|
||||||
-spec sign_tx(Request) -> ok
|
-spec sign_tx(Request) -> ok
|
||||||
when Request :: map().
|
when Request :: map().
|
||||||
|
|
||||||
@ -431,6 +439,9 @@ handle_cast({grids, String}, State) ->
|
|||||||
handle_cast({sign_mess, Request}, State) ->
|
handle_cast({sign_mess, Request}, State) ->
|
||||||
ok = do_sign_mess(Request, State),
|
ok = do_sign_mess(Request, State),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
handle_cast({sign_binary, Request}, State) ->
|
||||||
|
ok = do_sign_binary(Request, 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};
|
||||||
@ -679,23 +690,23 @@ do_grids_sig(JSON, URL) ->
|
|||||||
|
|
||||||
do_grids_sig2(Request = #{"grids" := 1, "type" := "message"}) ->
|
do_grids_sig2(Request = #{"grids" := 1, "type" := "message"}) ->
|
||||||
gd_gui:grids_mess_sig(Request);
|
gd_gui:grids_mess_sig(Request);
|
||||||
|
do_grids_sig2(Request = #{"grids" := 1, "type" := "binary"}) ->
|
||||||
|
gd_gui:grids_mess_sig(Request);
|
||||||
do_grids_sig2(Request = #{"grids" := 1, "type" := "tx"}) ->
|
do_grids_sig2(Request = #{"grids" := 1, "type" := "tx"}) ->
|
||||||
gd_gui:grids_mess_sig(Request);
|
gd_gui:grids_mess_sig(Request);
|
||||||
do_grids_sig2(WTF) ->
|
do_grids_sig2(WTF) ->
|
||||||
gd_gui:trouble({trash, WTF}).
|
gd_gui:trouble({trash, WTF}).
|
||||||
|
|
||||||
|
|
||||||
do_sign_mess(Request = #{"public_id" := ID, "payload" := Message},
|
do_sign_mess(Request = #{"public_id" := ID}, #s{wallet = #wallet{keys = Keys}}) ->
|
||||||
#s{wallet = #wallet{keys = Keys}}) ->
|
|
||||||
case lists:keyfind(ID, #key.id, Keys) of
|
case lists:keyfind(ID, #key.id, Keys) of
|
||||||
#key{pair = #{secret := SecKey}} ->
|
#key{pair = #{secret := SecKey}} -> do_sign_mess2(Request, SecKey);
|
||||||
Sig = base64:encode(hz:sign_message(list_to_binary(Message), SecKey)),
|
false -> gd_gui:trouble({bad_key, ID})
|
||||||
do_sign_mess2(Request#{"signature" => Sig});
|
|
||||||
false ->
|
|
||||||
gd_gui:trouble({bad_key, ID})
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_sign_mess2(Request = #{"url" := URL}) ->
|
do_sign_mess2(Request = #{"payload" := Message}, SecKey) ->
|
||||||
|
Sig = base64:encode(hz:sign_message(list_to_binary(Message), SecKey)),
|
||||||
|
SignedRequest = maps:put("signature", Sig, Request),
|
||||||
ResponseKeys =
|
ResponseKeys =
|
||||||
["grids",
|
["grids",
|
||||||
"chain",
|
"chain",
|
||||||
@ -704,11 +715,31 @@ do_sign_mess2(Request = #{"url" := URL}) ->
|
|||||||
"public_id",
|
"public_id",
|
||||||
"payload",
|
"payload",
|
||||||
"signature"],
|
"signature"],
|
||||||
Response = zj:encode(maps:with(ResponseKeys, Request)),
|
post_grids_response(ResponseKeys, SignedRequest).
|
||||||
case httpc:request(post, {URL, [], "application/json", Response}, [], []) of
|
|
||||||
{ok, {{_, 200, _}, _, JSON}} -> log(info, "Signature posted: ~p", [JSON]);
|
|
||||||
{error, socket_closed_remotely} -> tell("Yep, closed remotely.");
|
do_sign_binary(Request = #{"public_id" := ID}, #s{wallet = #wallet{keys = Keys}}) ->
|
||||||
Error -> gd_gui:trouble(Error)
|
case lists:keyfind(ID, #key.id, Keys) of
|
||||||
|
#key{pair = #{secret := SecKey}} -> do_sign_binary2(Request, SecKey);
|
||||||
|
false -> gd_gui:trouble({bad_key, ID})
|
||||||
|
end.
|
||||||
|
|
||||||
|
do_sign_binary2(Request = #{"payload" := Payload}, SecKey) ->
|
||||||
|
case base64_decode(Payload) of
|
||||||
|
{ok, Binary} ->
|
||||||
|
Sig = base64:encode(hz:sign_binary(Binary, SecKey)),
|
||||||
|
SignedRequest = maps:put("signature", Sig, Request),
|
||||||
|
ResponseKeys =
|
||||||
|
["grids",
|
||||||
|
"chain",
|
||||||
|
"network_id",
|
||||||
|
"type",
|
||||||
|
"public_id",
|
||||||
|
"payload",
|
||||||
|
"signature"],
|
||||||
|
post_grids_response(ResponseKeys, SignedRequest);
|
||||||
|
Error ->
|
||||||
|
gd_gui:trouble(Error)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
@ -719,20 +750,22 @@ do_sign_tx(Request = #{"public_id" := ID, "payload" := CallData, "network_id" :=
|
|||||||
#key{pair = #{secret := SecKey}} ->
|
#key{pair = #{secret := SecKey}} ->
|
||||||
BinaryTX = list_to_binary(CallData),
|
BinaryTX = list_to_binary(CallData),
|
||||||
SignedTX = hz:sign_tx(BinaryTX, SecKey, BinNID),
|
SignedTX = hz:sign_tx(BinaryTX, SecKey, BinNID),
|
||||||
do_sign_tx2(Request#{"signed" => true, "payload" := SignedTX});
|
SignedRequest = Request#{"signed" => true, "payload" := SignedTX},
|
||||||
|
ResponseKeys =
|
||||||
|
["grids",
|
||||||
|
"chain",
|
||||||
|
"network_id",
|
||||||
|
"type",
|
||||||
|
"public_id",
|
||||||
|
"payload",
|
||||||
|
"signed"],
|
||||||
|
post_grids_response(ResponseKeys, SignedRequest);
|
||||||
false ->
|
false ->
|
||||||
gd_gui:trouble({bad_key, ID})
|
gd_gui:trouble({bad_key, ID})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_sign_tx2(Request = #{"url" := URL}) ->
|
|
||||||
ResponseKeys =
|
post_grids_response(ResponseKeys, Request = #{"url" := URL}) ->
|
||||||
["grids",
|
|
||||||
"chain",
|
|
||||||
"network_id",
|
|
||||||
"type",
|
|
||||||
"public_id",
|
|
||||||
"payload",
|
|
||||||
"signed"],
|
|
||||||
Response = zj:encode(maps:with(ResponseKeys, Request)),
|
Response = zj:encode(maps:with(ResponseKeys, Request)),
|
||||||
case httpc:request(post, {URL, [], "application/json", Response}, [], []) of
|
case httpc:request(post, {URL, [], "application/json", Response}, [], []) of
|
||||||
{ok, {{_, 200, _}, _, JSON}} -> log(info, "Signed TX posted: ~p", [JSON]);
|
{ok, {{_, 200, _}, _, JSON}} -> log(info, "Signed TX posted: ~p", [JSON]);
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_grids).
|
-module(gd_grids).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_gui).
|
-module(gd_gui).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@ -1060,6 +1060,48 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
|||||||
?wxID_CANCEL -> ok
|
?wxID_CANCEL -> ok
|
||||||
end,
|
end,
|
||||||
wxDialog:destroy(Dialog);
|
wxDialog:destroy(Dialog);
|
||||||
|
do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||||
|
"type" := "binary",
|
||||||
|
"url" := URL,
|
||||||
|
"public_id" := ID,
|
||||||
|
"payload" := Base64},
|
||||||
|
#s{frame = Frame, j = J}) ->
|
||||||
|
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Binary Data Signature Request")),
|
||||||
|
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||||
|
Instruction =
|
||||||
|
J("The server at the URL below is requesting you sign the following binary data."),
|
||||||
|
InstTx = wxStaticText:new(Dialog, ?wxID_ANY, Instruction),
|
||||||
|
AcctSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Signature Account")}]),
|
||||||
|
AcctTx = wxStaticText:new(Dialog, ?wxID_ANY, ID),
|
||||||
|
_ = wxStaticBoxSizer:add(AcctSz, AcctTx, zxw:flags(wide)),
|
||||||
|
URL_Label = J("Originating URL"),
|
||||||
|
URL_Sz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, URL_Label}]),
|
||||||
|
URL_Tx = wxStaticText:new(Dialog, ?wxID_ANY, URL),
|
||||||
|
_ = wxStaticBoxSizer:add(URL_Sz, URL_Tx, zxw:flags(wide)),
|
||||||
|
MessSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Base-64 Data")}]),
|
||||||
|
MessStyle = ?wxTE_MULTILINE bor ?wxTE_READONLY,
|
||||||
|
MessTx = wxTextCtrl:new(Dialog, ?wxID_ANY, [{value, Base64}, {style, MessStyle}]),
|
||||||
|
_ = wxStaticBoxSizer:add(MessSz, MessTx, zxw:flags(wide)),
|
||||||
|
ButtSz = wxBoxSizer:new(?wxHORIZONTAL),
|
||||||
|
Affirm = wxButton:new(Dialog, ?wxID_OK),
|
||||||
|
Cancel = wxButton:new(Dialog, ?wxID_CANCEL),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Affirm, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(ButtSz, Cancel, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, InstTx, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, AcctSz, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, URL_Sz, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, MessSz, zxw:flags(wide)),
|
||||||
|
_ = wxBoxSizer:add(Sizer, ButtSz, zxw:flags(base)),
|
||||||
|
ok = wxDialog:setSizer(Dialog, Sizer),
|
||||||
|
ok = wxDialog:setSize(Dialog, {500, 500}),
|
||||||
|
ok = wxBoxSizer:layout(Sizer),
|
||||||
|
ok = wxFrame:center(Dialog),
|
||||||
|
ok =
|
||||||
|
case wxDialog:showModal(Dialog) of
|
||||||
|
?wxID_OK -> gd_con:sign_binary(Request);
|
||||||
|
?wxID_CANCEL -> ok
|
||||||
|
end,
|
||||||
|
wxDialog:destroy(Dialog);
|
||||||
do_grids_mess_sig2(Request = #{"grids" := 1,
|
do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||||
"type" := "tx",
|
"type" := "tx",
|
||||||
"url" := URL,
|
"url" := URL,
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
%%% translation library is retained).
|
%%% translation library is retained).
|
||||||
|
|
||||||
-module(gd_jt).
|
-module(gd_jt).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-export([read_translations/1, j/2, oneshot_j/2]).
|
-export([read_translations/1, j/2, oneshot_j/2]).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
-module(gd_sophia_editor).
|
-module(gd_sophia_editor).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-export([new/1, update/2,
|
-export([new/1, update/2,
|
||||||
get_text/1, set_text/2]).
|
get_text/1, set_text/2]).
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(gd_sup).
|
-module(gd_sup).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
-module(gd_v).
|
-module(gd_v).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
-module(gd_v_devman).
|
-module(gd_v_devman).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-author("Craig Everett <craigeverett@qpq.swiss>").
|
-author("Craig Everett <craigeverett@qpq.swiss>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
-module(gd_v_netman).
|
-module(gd_v_netman).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
-module(gd_v_wallman).
|
-module(gd_v_wallman).
|
||||||
-vsn("0.7.0").
|
-vsn("0.8.0").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("QPQ AG <info@qpq.swiss>").
|
-copyright("QPQ AG <info@qpq.swiss>").
|
||||||
-license("GPL-3.0-or-later").
|
-license("GPL-3.0-or-later").
|
||||||
@ -318,7 +318,7 @@ do_open2(Selected, State = #s{wallets = Wallets}) ->
|
|||||||
|
|
||||||
do_open3(Path, State = #s{frame = Frame, j = J}) ->
|
do_open3(Path, State = #s{frame = Frame, j = J}) ->
|
||||||
Label = J("Password"),
|
Label = J("Password"),
|
||||||
case zxw_text_modal:show(Frame, Label, [{password, true}]) of
|
case zxw_modal_text:show(Frame, Label, [{password, true}]) of
|
||||||
{ok, ""} ->
|
{ok, ""} ->
|
||||||
ensure_shown(Frame);
|
ensure_shown(Frame);
|
||||||
{ok, Phrase} ->
|
{ok, Phrase} ->
|
||||||
|
|||||||
@ -2,10 +2,10 @@
|
|||||||
{type,gui}.
|
{type,gui}.
|
||||||
{modules,[]}.
|
{modules,[]}.
|
||||||
{prefix,"gd"}.
|
{prefix,"gd"}.
|
||||||
{author,"Craig Everett"}.
|
|
||||||
{desc,"A desktop client for the Gajumaru network of blockchain networks"}.
|
{desc,"A desktop client for the Gajumaru network of blockchain networks"}.
|
||||||
{package_id,{"otpr","gajudesk",{0,7,0}}}.
|
{author,"Craig Everett"}.
|
||||||
{deps,[{"otpr","hakuzaru",{0,6,1}},
|
{package_id,{"otpr","gajudesk",{0,8,0}}}.
|
||||||
|
{deps,[{"otpr","hakuzaru",{0,7,0}},
|
||||||
{"otpr","eblake2",{1,0,1}},
|
{"otpr","eblake2",{1,0,1}},
|
||||||
{"otpr","base58",{0,1,1}},
|
{"otpr","base58",{0,1,1}},
|
||||||
{"otpr","gmserialization",{0,1,3}},
|
{"otpr","gmserialization",{0,1,3}},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user