Skip to content

Commit

Permalink
Create Account public key
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Jan 28, 2021
1 parent bdff8f2 commit 183417c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/cardano_wallet/shelley.rb
Expand Up @@ -77,6 +77,15 @@ def get_public_key(wid, role, index)
self.class.get("/wallets/#{wid}/keys/#{role}/#{index}")
end

# @see https://input-output-hk.github.io/cardano-wallet/api/#operation/postAccountKey
def create_acc_public_key(wid, index, pass, extended)
payload = { passphrase: pass, extended: extended }
self.class.post("/wallets/#{wid}/keys/#{index}",
:body => payload.to_json,
:headers => { 'Content-Type' => 'application/json' }
)
end

end

# API for Wallets
Expand Down
18 changes: 18 additions & 0 deletions spec/shelley_spec.rb
Expand Up @@ -732,6 +732,24 @@
end
end

it "Create account public key - extended = true" do
wid = create_shelley_wallet
["0H", "1H", "2147483647H", "44H"].each do |index|
res = SHELLEY.keys.create_acc_public_key(wid, index, PASS, extended = true)
expect(res).to include "acc"
expect(res.code).to eq 202
end
end

it "Create account public key - extended = false" do
wid = create_shelley_wallet
["0H", "1H", "2147483647H", "44H"].each do |index|
res = SHELLEY.keys.create_acc_public_key(wid, index, PASS, extended = false)
expect(res).to include "acc"
expect(res.code).to eq 202
end
end

end

end

0 comments on commit 183417c

Please sign in to comment.