Skip to content

Commit 8171265

Browse files
authored
createVLv2 (UNL list version 2 with future activation) (#61)
1 parent 1002c26 commit 8171265

File tree

15 files changed

+1021
-644
lines changed

15 files changed

+1021
-644
lines changed

README.md

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $ npm install --save @bithomp/xrpl-api
1414

1515
# Examples of use
1616

17-
## Account info
17+
## Get account info
1818

1919
```JS
2020
const BithompXRPL = require("@bithomp/xrpl-api");
@@ -56,7 +56,7 @@ const accountInfo = await BithompXRPL.Client.getAccountInfo("rsuUjfWxrACCAwGQDsN
5656
BithompXRPL.Client.disconnect();
5757
```
5858

59-
## Create Validator List
59+
## Create Validator List version 1
6060

6161
_Setup connection_, it is required to get validators details from the ledger.
6262

@@ -75,22 +75,26 @@ BithompXRPL.Client.setup(config);
7575
// connect
7676
await BithompXRPL.Client.connect();
7777

78-
// validator secrets, should not belong to any validators keys. can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used,
78+
// validator secrets, should not belong to any validators keys.
79+
// can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used,
7980
// can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs
8081
const vk = {
8182
privateKey: "p__________________________",
8283
publicKey: "ED________________________________",
8384
};
8485

85-
// signing secrets, should not belong to any validators keys. can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used
86+
// signing secrets, should not belong to any validators keys.
87+
// can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used,
8688
// can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs
8789
const sk = {
8890
privateKey: "p__________________________",
8991
publicKey: "ED_______________________________",
9092
};
9193

92-
// validator list, public addresses, they have to be available on the ledger for accessing to manifest data (it will be stored in a blob), the address should start on letter `n`
93-
const validators = ["nHBidG3pZK11zQD6kpNDoAhDxH6WLGui6ZxSbUx7LSqLHsgzMPec"];
94+
// validator list, public addresses, they have to be available on the ledger
95+
// for accessing to manifest data (it will be stored in a blob),
96+
// the address should start with `n`
97+
const validators = ["nHB8QMKGt9VB4Vg71VszjBVQnDW3v3QudM4DwFaJfy96bj4Pv9fA"];
9498
const sequence = 1; // sequence number
9599
const expiration = 1696508603; // in unixtime (seconds)
96100
const vl = await BithompXRPL.Client.createVL(vk, sk, sequence, expiration, validators);
@@ -108,6 +112,69 @@ const vl = await BithompXRPL.Client.createVL(vk, sk, sequence, expiration, valid
108112
BithompXRPL.Client.disconnect();
109113
```
110114

115+
## Create Validator List version 2
116+
117+
_Setup connection_, it is required to get validators details from the ledger.
118+
119+
```JS
120+
const BithompXRPL = require("@bithomp/xrpl-api");
121+
// setup connection
122+
const config = [
123+
{
124+
// this connection will be used to get validators details from the ledger, use web socket with connection to network you are building list for (mainnet, testnet, devnet, etc.)
125+
"url": "wss://xrplcluster.com",
126+
"connectionTimeout": 10000
127+
}
128+
];
129+
BithompXRPL.Client.setup(config);
130+
131+
// connect
132+
await BithompXRPL.Client.connect();
133+
134+
// validator secrets, should not belong to any validators keys.
135+
// can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used,
136+
// can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs
137+
const vk = {
138+
privateKey: "p__________________________",
139+
publicKey: "ED________________________________",
140+
};
141+
142+
// signing secrets, should not belong to any validators keys.
143+
// can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used,
144+
// can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs
145+
const sk = {
146+
privateKey: "p__________________________",
147+
publicKey: "ED_______________________________",
148+
};
149+
150+
// validator list, public addresses, they have to be available on the ledger
151+
// for accessing to manifest data (it will be stored in a blob),
152+
// the address should start with `n`
153+
const publishBlobCurrent = {
154+
sequence: 1, // sequence number
155+
expiration: 1696508603,
156+
validatorsPublicKeys: ["nHUFE9prPXPrHcG3SkwP1UzAQbSphqyQkQK9ATXLZsfkezhhda3p"],
157+
};
158+
const publishBlobFuture = {
159+
sequence: 2, // sequence number
160+
effective: 1696508603, // optional in unixtime (seconds)
161+
expiration: 1723620871, // in unixtime (seconds)
162+
validatorsPublicKeys: ["nHB8QMKGt9VB4Vg71VszjBVQnDW3v3QudM4DwFaJfy96bj4Pv9fA"],
163+
};
164+
const vl = await BithompXRPL.Client.createVLv2(vk, sk, [publishBlob, publishBlobFuture]);
165+
166+
// vl will contain the signed validator list with
167+
// {
168+
// "blobs-v2": "...",
169+
// "manifest": "...", // signed with vk.privateKey and sk.privateKey
170+
// "version": 2,
171+
// "public_key": "..." // vk.publicKey
172+
// }
173+
174+
// disconnect
175+
BithompXRPL.Client.disconnect();
176+
```
177+
111178
## Decode NFTokenID
112179

113180
```JS
@@ -137,7 +204,8 @@ const issuer = "rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2";
137204
const nftokenTaxon = 146999694;
138205
const sequence = 3429;
139206

140-
// NOTE: This function is not minting NFTokenID, it is just encoding it from the data provided, can be used if you want to test something, check if the NFTokenID is valid, or predict the NFTokenID before minting
207+
// NOTE: This function is not minting NFTokenID, it is just encoding it from the data provided,
208+
// can be used if you want to test something, check if the NFTokenID is valid, or predict the NFTokenID before minting
141209
const result = BithompXRPL.Models.buildNFTokenID(flags, transferFee, issuer, nftokenTaxon, sequence);
142210
// result will contain NFTokenID
143211
// "000B0C4495F14B0E44F78A264E41713C64B5F89242540EE2BC8B858E00000D65"

0 commit comments

Comments
 (0)