Ripple

如何使用ripple-lib javascript 庫生成Ripple 地址和密碼?

  • May 31, 2018

波紋客戶端應用程序可以使用橢圓曲線算法生成新帳戶。是否有執行此任務的高級功能?

是的,你寫了一個很好的腳本。 <https://github.com/stevenzeiler/ripple-wallet>

您可以使用此腳本。它會生成一個秘密和一個地址,並且通過使用 libraryripple-keypairs,您也可以獲得私鑰和公鑰。

'use strict';
const RippleAPI = require('ripple-lib').RippleAPI;
var test_server = 'wss://s2.ripple.com';
var keypairs = require('ripple-keypairs');
const api = new RippleAPI({
   server: test_server // Public rippled server
});
api.connect().then(() =&gt; { 
   /* begin custom code ------------------------------------ */
   return api.generateAddress();
}).then(address_info =&gt; {
   console.log("Secret: " + address_info.secret);
   console.log("Address: " + address_info.address);
   var keypair = keypairs.deriveKeypair(address_info.secret);
   var privateKey = keypair.privateKey;
   console.log("Private key: " + privateKey);
   var publicKey = keypair.publicKey;
   console.log("Public key: " + publicKey);
   var address = keypairs.deriveAddress(keypair.publicKey);
   console.log("Address: " + address);
   /* end custom code -------------------------------------- */
}).then(() =&gt; {
   return api.disconnect();
}).then(() =&gt; {
   console.log('done and disconnected.');
}).catch(console.error);

祝你好運=)

引用自:https://bitcoin.stackexchange.com/questions/20366