input-output-hk / js-cardano-wasm

various cardano javascript using wasm bindings
MIT License
31 stars 21 forks source link

What is module param in the method? #12

Closed rahilzebpay closed 6 years ago

rahilzebpay commented 6 years ago
export const publicKeyToAddress = (module, xpub, payload) => {
  const bufxpub    = newArray(module, xpub);
  const bufpayload = newArray(module, payload);
  const bufaddr    = newArray0(module, 1024);

  let rs = module.wallet_public_to_address(bufxpub, bufpayload, payload.length, bufaddr);
  let addr = copyArray(module, bufaddr, rs);

  module.dealloc(bufaddr);
  module.dealloc(bufpayload);
  module.dealloc(bufxpub);

  return addr;
};

Thanks.

NicolasDP commented 6 years ago

it is the Wasm module. It is passed as parameter. I believe it was an attempt to leverage that we needed some time to load the wasm module.

@DominikGuzei migth be able to help here.

rahilzebpay commented 6 years ago

Thanks. I got that part. So now I load the module and pass it to the function.

Just wanted to confirm. This library designed to work on browsers right? I was actually trying to run it on Node.js but ended up getting invalid addresses.

NicolasDP commented 6 years ago

if you are trying to recreates Daedalus addresses this is not possible with this library (yet). We may spend some time allowing compatibility in the future. see #5

I guess we can close this issue then.

rahilzebpay commented 6 years ago

No I'm not trying to recreate Daedalus addresses.

I'm just trying to generate addresses using this library. By Invalid I didn't mean that it was different to what Daedalus returned rather the explorer says invalid address. Maybe I'm doing something wrong.

Would you be kind enough to provide me an example of generating addresses with xPub using this library? I'm trying to use functions from this API https://github.com/input-output-hk/js-cardano-wasm/blob/master/js/HdWallet.js

NicolasDP commented 6 years ago

It depends mainly on the kind of the kind of address derivation you want to use. For now most of the APIs you see are very low level and might change or disappear in the future.

Please, keep in mind that all of this library is a Work in Progress and that it is not tested for production environment (i.e. mainnet).

If you are using bip44 and sequential addresses, I suggest you use the Wallet module for generating new addresses.