Externally Stored private keys and usage

+2 votes

With respect to your reply : If you want multiple nodes to act as exact replicas in terms of funds they hold and other transactions they sign, the one issue will be if you store private keys in MultiChain's internal wallet (rather than externally which is also an option). In that case you can use APIs like dumpprivkey and importprivkey to transfer keys between nodes and ensure they are working to the same key set.

Can you please highlight how to store the keys externally and how to use them in transactions.? A sample will be of great help.

 

Thanks

related to an answer for: Back up and Recovery Best Practices
asked Dec 14, 2016 by anonymous

1 Answer

0 votes

Here's the basic way to do this, for a cluster of redundant nodes:

  1. Use createkeypairs on any one node to generate an address and private key (you can also pass a parameter to generate many such pairs in one go).
  2. Store the privkey/s it gave you in your own database.
  3. Use importaddress to start tracking the address/es it gave you, on every node in the cluster. Assuming this address has not been used yet, you can set the parameter rescan=false for efficiency.
  4. Use createrawsendfrom on any node to build an unsigned raw transaction which does something from a particular address. With the appropriate parameters, this can be used to send funds, change permissions, issue assets, create streams, publish to streams, etc... See this page for detailed documentation: http://www.multichain.com/developers/raw-transactions/
  5. Use signrawtransaction to sign this transaction on any node, passing in the private key you are storing externally in the appropriate parameter.
  6. Use sendrawtransaction on any node to send the final signed transaction.

Depending on how adventurous you're feeling, steps 4 and 5 can also be done using external bitcoin-compatible libraries to build the transaction and sign it. That will be a little quicker and require fewer MultiChain API calls, but I wouldn't recommend it to start with, since it requires an understanding of how MultiChain represents things internally in transactions, as well as its private key format. But all this is documented on the site if you want it.

answered Dec 14, 2016 by MultiChain
The method 'createkeypairs' doesnt work on multichain version 1.0 alpha 25, but works on alpha 27
That's right, it's a recent addition.
...