我正试着用官方的Ripple Api,纹波库创建一个纸钱包。
generateAddress()接受一些参数。
'use strict';
const RippleAPI = require('ripple-lib').RippleAPI;
const api = new RippleAPI({
server: 'wss://s1.ripple.com' // Public rippled server
});
api.connect().then(() => {
return api.generateAddress();
}).then(info => {
console.log(info);
console.log('getAccountInfo done');
/* end custom code -------------------------------------- */
}).then(() => {
return api.disconnect();
}).then(() => {
console.log('done and disconnected.');
}).catch(console.error);这个代码实际上创建了一个秘密密钥和一个“地址”。
{
secret: 'sheWb..................HRyLhk',
address: 'rNLJ.......................qu3nbb'
}好的。现在我已经创建了我的账户。如果我用20 And储备为其提供资金,它将成为活跃的Ripple账户。耶!
但我不明白:
有人能对这些问题有所了解吗?
编辑:--我认为传递给generateAddress()的options对象与传递给这里描述的构造函数的options参数相同,https://ripple.com/build/rippleapi/#parameters可以确认这一点吗?
发布于 2018-05-28 19:25:55
对于纸质钱包,你只需要address(public)和secret(private):
https://github.com/Bithomp/xrp-paper-wallet
实际上,只有机密就足够了,因为您可以从获得地址。
https://github.com/Bithomp/bithomp-tools
在Ripple中,您不必为每个新订单/用户使用新帐户。对于每个新事务,您都可以使用一个目标标记。这就是你可以识别客户/订单的方法。纹章还支持密钥旋转,所以如果主键暴露了,您可以禁用它并使用正则键。在最佳实践中,您将分配一个常规密钥,并使用它对联机事务进行签名,并使主密钥始终脱机。如果公开了一个常规密钥,您可以用一个新的常规密钥替换它。
您可以使用密钥区(公钥+私钥)或机密对事务进行签名。
您可以在这里获得用于纹章的键盘,https://iancoleman.io/bip39/
纹章库的generateAddress()提供给您:
1)波纹式的地址(您的公共地址)从r开始
你可以分享它,它可以用来给你付款。可以在资源管理器中搜索公共地址。
例如:https://bithomp.com/explorer/r9fVvKgMMPkBHQ3n28sifxi22zKphwkf8u
2) --主密钥,用于签署事务。
3)您还可以分配一个正则密钥 (https://developers.ripple.com/assign-a-regular-key-pair.html)
选项只有两个参数:
希望能帮上忙..。
发布于 2019-10-17 04:22:03
generateAddress()方法接受三个参数。在这里描述:https://ripple.com/build/rippleapi/#generateaddress,但我不知道如何编写这些参数。我对此很感兴趣,因为我认为在第一个参数中,"options“对象是我可以为秘密密钥定义密码短语的地方。也许我错了。
这里有一些javascript代码来演示熵在generateAddress方法中的输入。
// This functions works on modern browswers, not sure about Node.js. Try https://www.npmjs.com/package/js-sha512 or https://nodejs.org/api/crypto.html
async function fun_SHA512_array(entropy) {
'use strict';
// Turns a string into an array of integers.
// Made possible by https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
const msgUint8 = new TextEncoder().encode(entropy); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-512', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
// const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashArray;
}
const str_entropy = "Use a cryptographically strong, randomly created string of characters here.";
// Or, your passphrase string would go here.
// Or, you could use a BIP39 Mnemonic but you'd have to remember how you constructed the string. e.g. Did you separate the words with a comma or with a space?
// Or, on the linux terminal you can use: openssl rand -base64 n
// Where n = the number of characters you wish to randomly generate. Which are then converted to base64, therefore the amount of characters ends up being more than n.
var array_sha512 = [];
fun_SHA512_array(str_entropy).then(array_sha512 => {
var obj_new_account = api.generateAddress({"entropy": array_sha512});
var str_secret = obj_new_account.secret;
var str_public_address = obj_new_account.address;
console.log(str_secret);
console.log(str_public_address);
});请记住,熵就像一个种子,并且总是生成相同的秘密和address。
https://stackoverflow.com/questions/48219353
复制相似问题