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

Add example on how to use a custom network #383

Closed
dcousens opened this issue Mar 16, 2015 · 5 comments
Closed

Add example on how to use a custom network #383

dcousens opened this issue Mar 16, 2015 · 5 comments
Assignees
Milestone

Comments

@dcousens
Copy link
Contributor

Probably just need to outline something like the following:

var viacoin = {
  bip32: {
    public: 0x0488b21e,
    private: 0x0488ade4
  },
  dustThreshold: 560,
  feePerKb: 100000,
  magicPrefix: '\x18Viacoin Signed Message:\n',
  pubKeyHash: 0x47,
  scriptHash: 0x21,
  wif: 0xc7
}

The above is 1.5.x compatible, for 2.0.0 see here.

@dcousens dcousens self-assigned this Mar 16, 2015
@dcousens dcousens added this to the 2.0.0 milestone Mar 16, 2015
@dcousens dcousens removed the feature label May 7, 2015
@dcousens dcousens changed the title Add example on how to add own network Add example on how to use a custom network May 20, 2015
@ricmoo
Copy link

ricmoo commented Aug 13, 2015

Another useful note would be what fields are required for which parts of the library? For example, to just encode/decode from WIF, only wif is necessary.

There do not seem to exist BIP32 prefixes for Namecoin (although I have generated some that generate a prefix of n, if interested... Is this the right thing to do? Or just use bitcoin's?), but they can be simply omitted if you are not using HDNode.

It would be nice to know when defining custom networks what is required for my feature set.

@jprichardson
Copy link
Member

@ricmoo regarding BIP32 prefixes for different coins, I wouldn't recommend doing so as it's pretty redundant (assuming you follow BIP44). See https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki#node-serialization for more detail. i.e. using bitcoinjs-libwith a custom network in most cases will require you making sure that you have the WIF version correct. Take note though, that proof-of-stake coins do require different deserialization/serialization of transactions (due to the timestamp) - I'm working on a solution to address this, but it may be awhile.

@ricmoo
Copy link

ricmoo commented Aug 13, 2015

Oh! That is PERFECT. I have been looking for that info documented somewhere. I noticed a few random alt-coins used their own prefixes.

Thanks. :)

@dcousens
Copy link
Contributor Author

As of 2.0.0, the network type format would be aligned to this example:

  bitcoin: {
    messagePrefix: '\x18Bitcoin Signed Message:\n',
    bip32: {
      public: 0x0488b21e,
      private: 0x0488ade4
    },
    pubKeyHash: 0x00,
    scriptHash: 0x05,
    wif: 0x80,
    dustThreshold: 546
  },

@dcousens
Copy link
Contributor Author

@jprichardson (and others) for what its worth, you should still specify the network object when calling HDNode.fromBase58, as it will default to bitcoin otherwise.

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

3 participants