Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82ea4ea7ec | |||
| feae15740a |
@ -1,5 +1,5 @@
|
|||||||
@author Craig Everett <craigeverett@qpq.swiss> [https://git.qpq.swiss/QPQ-AG/hakuzaru]
|
@author Craig Everett <craigeverett@qpq.swiss> [https://git.qpq.swiss/QPQ-AG/hakuzaru]
|
||||||
@version 0.8.0
|
@version 0.8.2
|
||||||
@title Hakuzaru: Gajumaru blockchain bindings for Erlang
|
@title Hakuzaru: Gajumaru blockchain bindings for Erlang
|
||||||
|
|
||||||
@doc
|
@doc
|
||||||
@ -35,7 +35,7 @@ ceverett@steak:~$ zxh run hakuzaru
|
|||||||
Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
|
Erlang/OTP 27 [erts-15.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
|
||||||
|
|
||||||
Eshell V15.2 (press Ctrl+G to abort, type help(). for help)
|
Eshell V15.2 (press Ctrl+G to abort, type help(). for help)
|
||||||
Fetching otpr-hakuzaru-0.8.0
|
Fetching otpr-hakuzaru-0.8.2
|
||||||
[100.00%]
|
[100.00%]
|
||||||
Recompile: src/hz_sup
|
Recompile: src/hz_sup
|
||||||
Recompile: src/hz_man
|
Recompile: src/hz_man
|
||||||
@ -45,7 +45,7 @@ Recompile: src/hz_format
|
|||||||
Recompile: src/hz_fetcher
|
Recompile: src/hz_fetcher
|
||||||
Recompile: src/hz
|
Recompile: src/hz
|
||||||
Recompile: src/hakuzaru
|
Recompile: src/hakuzaru
|
||||||
Starting otpr-hakuzaru-0.8.0.
|
Starting otpr-hakuzaru-0.8.2.
|
||||||
hz_man starting.
|
hz_man starting.
|
||||||
Started [hakuzaru]
|
Started [hakuzaru]
|
||||||
1> hz:chain_nodes([{"groot.testnet.gajumaru.io", 3013}]).
|
1> hz:chain_nodes([{"groot.testnet.gajumaru.io", 3013}]).
|
||||||
|
|||||||
13
src/hz.erl
13
src/hz.erl
@ -2461,6 +2461,19 @@ spend3(DSenderID,
|
|||||||
hz:post_tx(Encoded).
|
hz:post_tx(Encoded).
|
||||||
|
|
||||||
|
|
||||||
|
-spec sign(Scheme, Target, SecKey) -> Sig
|
||||||
|
when Scheme :: message | binary | bitcoin,
|
||||||
|
Target :: binary(),
|
||||||
|
SecKey :: binary(),
|
||||||
|
Sig :: binary().
|
||||||
|
|
||||||
|
sign(message, Target, SecKey) -> sign_message(Message, SecKey);
|
||||||
|
sign(binary, Target, SecKey) -> sign_binary(Target, SecKey);
|
||||||
|
sign(bitcoin, Target, SecKey) -> sign_bitcoin(Target, SecKey).
|
||||||
|
|
||||||
|
sign(bitcoin, Target, SecKey) -> sign_message(Target, SecKey).
|
||||||
|
|
||||||
|
|
||||||
-spec sign_message(Message, SecKey) -> Sig
|
-spec sign_message(Message, SecKey) -> Sig
|
||||||
when Message :: binary(),
|
when Message :: binary(),
|
||||||
SecKey :: binary(),
|
SecKey :: binary(),
|
||||||
|
|||||||
@ -190,16 +190,48 @@ l_to_i(S) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
-spec req(Type, Message) -> RequestMap
|
||||||
|
when Type :: {sign, message | binary | bitcoin}
|
||||||
|
| tx
|
||||||
|
| ack
|
||||||
|
| sign,
|
||||||
|
Message :: binary(),
|
||||||
|
RequestMap :: map().
|
||||||
|
%% @doc
|
||||||
|
%% GRIDS maps always contain the following keys:
|
||||||
|
%% ```
|
||||||
|
%% #{"grids" => 1,
|
||||||
|
%% "chain" => "gajumaru",
|
||||||
|
%% "network_id" => "groot.mainnet.gajumaru.io",
|
||||||
|
%% "type" => "message" | "binary" | "binary" | "tx" | "ack"
|
||||||
|
%% "public_id" => term(),
|
||||||
|
%% "payload" => string()};
|
||||||
|
%% '''
|
||||||
|
|
||||||
req(Type, Message) ->
|
req(Type, Message) ->
|
||||||
req(Type, Message, false).
|
req(Type, Message, false).
|
||||||
|
|
||||||
req(sign, Message, ID) ->
|
req({sign, message}, Message, ID) ->
|
||||||
#{"grids" => 1,
|
#{"grids" => 1,
|
||||||
"chain" => "gajumaru",
|
"chain" => "gajumaru",
|
||||||
"network_id" => hz:network_id(),
|
"network_id" => hz:network_id(),
|
||||||
"type" => "message",
|
"type" => "message",
|
||||||
"public_id" => ID,
|
"public_id" => ID,
|
||||||
"payload" => Message};
|
"payload" => Message};
|
||||||
|
req({sign, binary}, Binary, ID) ->
|
||||||
|
#{"grids" => 1,
|
||||||
|
"chain" => "gajumaru",
|
||||||
|
"network_id" => hz:network_id(),
|
||||||
|
"type" => "binary",
|
||||||
|
"public_id" => ID,
|
||||||
|
"payload" => base64:encode(Binary)};
|
||||||
|
req({sign, bitcoin}, Binary, ID) ->
|
||||||
|
#{"grids" => 1,
|
||||||
|
"chain" => "gajumaru",
|
||||||
|
"network_id" => hz:network_id(),
|
||||||
|
"type" => "bitcoin",
|
||||||
|
"public_id" => ID,
|
||||||
|
"payload" => base64:encode(Binary)};
|
||||||
req(tx, Data, ID) ->
|
req(tx, Data, ID) ->
|
||||||
#{"grids" => 1,
|
#{"grids" => 1,
|
||||||
"chain" => "gajumaru",
|
"chain" => "gajumaru",
|
||||||
@ -213,4 +245,6 @@ req(ack, Message, ID) ->
|
|||||||
"network_id" => hz:network_id(),
|
"network_id" => hz:network_id(),
|
||||||
"type" => "ack",
|
"type" => "ack",
|
||||||
"public_id" => ID,
|
"public_id" => ID,
|
||||||
"payload" => Message}.
|
"payload" => Message};
|
||||||
|
req(sign, Message, ID) ->
|
||||||
|
req({sign, message}, Message, ID).
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user