Skip to content

Commit

Permalink
fixup add ./bin/create-ecdsa-wallet script
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev Berman committed Jan 8, 2025
1 parent 17fb09d commit bfff0e0
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions apps/arweave/src/ar.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

-behaviour(application).

-export([main/0, main/1, create_wallet/0, create_wallet/1,
-export([main/0, main/1, create_wallet/0, create_wallet/1, create_ecdsa_wallet/1,
benchmark_packing/1, benchmark_packing/0, benchmark_2_9/0, benchmark_2_9/1,
benchmark_vdf/0,
benchmark_hash/1, benchmark_hash/0, start/0,
start/1, start/2, stop/1, stop_dependencies/0, start_dependencies/0,
tests/0, tests/1, tests/2, e2e/0, e2e/1, shell/0, stop_shell/0,
docs/0, shutdown/1, console/1, console/2]).

-include_lib("arweave/include/ar.hrl").
-include_lib("arweave/include/ar_consensus.hrl").
-include_lib("arweave/include/ar_config.hrl").
-include("../include/ar.hrl").
-include("../include/ar_consensus.hrl").
-include("../include/ar_config.hrl").

-include_lib("eunit/include/eunit.hrl").

Expand Down Expand Up @@ -794,12 +794,22 @@ set_mining_address(#config{ mining_addr = Addr, cm_exit_peer = CmExitPeer,
end.

create_wallet([DataDir]) ->
create_wallet(DataDir, ?RSA_KEY_TYPE);
create_wallet(_) ->
create_wallet_fail(?RSA_KEY_TYPE).

create_ecdsa_wallet([DataDir]) ->
create_wallet(DataDir, ?ECDSA_KEY_TYPE);
create_ecdsa_wallet(_) ->
create_wallet_fail(?ECDSA_KEY_TYPE).

create_wallet(DataDir, KeyType) ->
case filelib:is_dir(DataDir) of
false ->
create_wallet_fail();
create_wallet_fail(KeyType);
true ->
ok = application:set_env(arweave, config, #config{ data_dir = DataDir }),
case ar_wallet:new_keyfile({?RSA_SIGN_ALG, 65537}) of
case ar_wallet:new_keyfile(KeyType) of
{error, Reason} ->
ar:console("Failed to create a wallet, reason: ~p.~n~n",
[io_lib:format("~p", [Reason])]),
Expand All @@ -810,15 +820,16 @@ create_wallet([DataDir]) ->
ar:console("Created a wallet with address ~s.~n", [ar_util:encode(Addr)]),
erlang:halt()
end
end;
create_wallet(_) ->
create_wallet_fail().
end.

create_wallet() ->
create_wallet_fail().
create_wallet_fail(?RSA_KEY_TYPE).

create_wallet_fail() ->
create_wallet_fail(?RSA_KEY_TYPE) ->
io:format("Usage: ./bin/create-wallet [data_dir]~n"),
erlang:halt();
create_wallet_fail(?ECDSA_KEY_TYPE) ->
io:format("Usage: ./bin/create-ecdsa-wallet [data_dir]~n"),
erlang:halt().

benchmark_packing() ->
Expand Down

0 comments on commit bfff0e0

Please sign in to comment.