Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

BIP39 Keystore not accessible from keystore parameter path #68

Closed
pandeyshivang opened this issue Apr 20, 2018 · 11 comments
Closed

BIP39 Keystore not accessible from keystore parameter path #68

pandeyshivang opened this issue Apr 20, 2018 · 11 comments

Comments

@pandeyshivang
Copy link

pandeyshivang commented Apr 20, 2018

let userDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]

     let ks = KeystoreManager.managerForPath(userDir + "/keystore")
    self.keystoreManager = ks
    web3rinky?.addKeystoreManager(ks)
  
    address = ks?.addresses?[0].address

crash when getting address from keystoremanager.
Error in latest version in CryptoSwift?

@pandeyshivang pandeyshivang changed the title BIP39 Keystore not acceble from keystore parameter path BIP39 Keystore not accessible from keystore parameter path Apr 20, 2018
@shamatar
Copy link
Contributor

Did you previously create a BIP32 keystore and save it to that directory? Just in case

@pandeyshivang
Copy link
Author

yeah i want to create hd wallet
let mnemonic = try! BIP39.generateMnemonics(bitsOfEntropy: 256)!
let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: password, mnemonicsPassword: "")
let keydata = try JSONEncoder().encode(ks?.keystoreParams)
FileManager.default.createFile(atPath: userDir + "/keystore"+"/key.json", contents: keydata, attributes: nil)

@pandeyshivang
Copy link
Author

pandeyshivang commented Apr 20, 2018

@shamatar I have just solved it...

 let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
  let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
  let bip32keystore = BIP32Keystore.init(data)

@shamatar thanks giving me this fantastic lib.

@shamatar
Copy link
Contributor

Oh, I didn’t understand a question. Yes, you can either create a keystore from phrase and lib will save a necessary information to JSON that you can write to disk, or you can supply either Json string or data to recreate it from saved copy.

@shamatar
Copy link
Contributor

Please keep in mind that BIP 32 keystore JSON format is not standartized, so files are not compatible with other libs. For BIP32KEYSTORE keystore everyone just backups a seed phrase, it’s enough. Be sure to allow your users to backup a seed phrase after creation and destroy it after

@pandeyshivang
Copy link
Author

pandeyshivang commented Apr 20, 2018

@shamatar but get connectionError in Send ether.
responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength)
2018-04-20 17:06:54.178363+0530 Ethereum-ERC20-Tokens-Wallet[10263:227250]

@shamatar
Copy link
Contributor

shamatar commented Apr 20, 2018 via email

@pandeyshivang
Copy link
Author

my internet is working fine and i am using infura and whenever i send i got invalid address.

@shamatar
Copy link
Contributor

shamatar commented Apr 20, 2018 via email

@pandeyshivang
Copy link
Author

pandeyshivang commented Apr 23, 2018

@shamatar yeah i installed latest version of web3swift. my code is send ether in bip32keystore...

let contract = self.web3rinky?.contract(Web3.Utils.coldWalletABI, at: toaddress) var options = Web3Options.defaultOptions() options.value = Web3.Utils.parseToBigUInt(amount, units: .eth) options.from = self.bip32keystore?.addresses?.first let intermediate = contract?.method("fallback", options: options) let result = intermediate?.send(password: pass)

@pandeyshivang
Copy link
Author

@shamatar Yeah it works in 0.5.6 version...

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

No branches or pull requests

2 participants