Skip to content

Commit

Permalink
Merge pull request #2 from mijkenator/master
Browse files Browse the repository at this point in the history
fixed bug in parser in start_link(proto://user:password@host:port)
  • Loading branch information
Eric des Courtis committed Aug 24, 2015
2 parents f3fc47f + 5bc5e7e commit 6e47d09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ Usage
4> ebitcoind:setgenerate(Pid,true).
{ok, null}
</pre>
OR you can specify connection information as start_link argument
<pre>
1> {ok,Pid} = ebitcoind:start_link(<<"http://rpcuser:rpcpassword@host:port">>).
{ok,<0.177.0>}
</pre>
11 changes: 6 additions & 5 deletions src/ebitcoind.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,11 @@ get_settings_from_bitcoin_conf(BitcoinConfPath) ->
url_to_bitcoin_jsonrpc_config(Url) when is_list(Url) ->
{ok, {HttpOrHttps, UserPass, Host, Port, _, _}} = http_uri:parse(Url),
{Username, Password} = userpass_to_username_and_password(UserPass),
C = fun unicode:characters_to_binary/1,
#bitcoin_jsonrpc_config{
user = Username,
password = Password,
host = Host,
user = C(Username),
password = C(Password),
host = C(Host),
port = Port,
ssl = case HttpOrHttps of https -> true; http -> false end
}.
Expand All @@ -1046,8 +1047,8 @@ userpass_to_username_and_password(0, User) ->
Def = #bitcoin_jsonrpc_config{},
{User, Def#bitcoin_jsonrpc_config.password};
userpass_to_username_and_password(Pos, UserPass) ->
User = string:substr(UserPass, Pos + 1),
Pass = string:substr(UserPass, 1, Pos - 1),
Pass = string:substr(UserPass, Pos + 1),
User = string:substr(UserPass, 1, Pos - 1),
{User, Pass}.

increment_seed(<<Num:?SEED_BYTES/unsigned-integer-unit:8>>) ->
Expand Down

0 comments on commit 6e47d09

Please sign in to comment.