Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating wallet from existing key #5

Closed
jsoneaday opened this issue Nov 3, 2021 · 3 comments
Closed

Creating wallet from existing key #5

jsoneaday opened this issue Nov 3, 2021 · 3 comments

Comments

@jsoneaday
Copy link

I'm trying to create a Data object based on the private key of an existing wallet that I have. In javascript if I json.parse this file's contents it does create the wallet. However in swift if I use Data(JSONEncoder().encode("{key}")) it exceptions on the Wallet line.

let walletData = try? Data(JSONEncoder().encode("my key")
let wallet = try Wallet(jwkFileData: walletData!) // fails here
@lukereichold
Copy link
Owner

@jsoneaday If you're trying to create a Data representation of a file's contents (the JWK keyfile), you can use the steps provided in the README:

guard let keyFileData = try? Data(contentsOf: keyFileUrl) else { return }
let wallet = Wallet(jwkFileData: keyFileData)

Do you mean to ask that you'd like to create a Data object directly from a JSON String (to subsequently use to create a Wallet)?

If so, in Swift you can convert a String to Data via the following:

let keyDataFromString = try jsonString.data(using: .utf8)

@jsoneaday
Copy link
Author

Thanks I'll try that. I'm getting someone on discord saying that your library does not work on arweave v2 using either testweave or arlocal, only v1. He says he gets http 412 errors. I'll try it on my end and see.

@lukereichold
Copy link
Owner

@jsoneaday This library currently supports only v1. I've responded in the Discord channel and will open a new issue here for v2 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants