Developer Resources
API Resources

Creating a Node Walkthrough

2min
this document will walk you through everything you need to know to create a node on voltage via the api first we'll describe the process then show a complete code example process here's the general process of creating a node via our api call the /node/create https //docs voltage cloud/voltage api#j5hew endpoint to create a node with your settings call the /node https //docs voltage cloud/voltage api#1ghgq endpoint every 5 or 10 seconds to check on the status of the node it's first status is provisioning after it's provisioned it will switch to status waiting init this means the node is waiting to be initialized now you should call /v1/genseed https //api lightning community/#v1 genseed on the node to generate a seed for yourself once you have a seed, you can initialize the wallet call the /v1/initwallet https //api lightning community/#v1 initwallet endpoint on the node pass in it the seed created in step #3 and a password you must also set stateless init true! if you don't then you won't be able to access the node this will return a macaroon in the api response after your node is initialized, you can encrypt the seed and macaroon to your password used for the node use the /node/upload seed https //docs voltage cloud/voltage api#ch54m and /node/macaroon https //docs voltage cloud/voltage api#5umdg endpoints to backup your encrypted seed and macaroon (give the macaroon a name of admin) that's it! your node's status should now be running and you can use your macaroon to connect we use tls certificates that are signed by a trusted certificate authority so it's not required to supply it when connecting however, there are some applications that require it nonetheless if you encounter one, you can get your node's certificate with the /node/cert https //docs voltage cloud/voltage api#enpiz endpoint example here is an example script written in node js this script would create a node, initialize it, and upload the encrypted backups const axios = require('axios') const crypto = require('crypto js') // define your variables let apikey = "your api key here" let nodename = "voltage example" let nodepassword = "your secure password" let orgid = "your org id" async function main() { console log("creating your node ") voltageheaders = { 'x voltage auth' apikey, } // create the node creationbody = { network "testnet", purchased type "ondemand", type "standard", name nodename, settings { alias nodename, autocompaction false, autopilot false, color "#ef820d", grpc true, keysend true, rest true, whitelist \[ "1 2 3 4" ], wumbo true } } response = await makerequest('post', 'https //api voltage cloud/organizations/' + orgid + '/node/create', creationbody, voltageheaders) nodeid = response node id console log("created the node "+nodeid) // wait until the node is waiting init do { statusbody = { node id nodeid } response = await makerequest('post', 'https //api voltage cloud/organizations/' + orgid + '/node', statusbody, voltageheaders) nodestatus = response status nodeapi = response api endpoint console log("found node's status of "+nodestatus) // wait 5 seconds before checking again await new promise(r => settimeout(r, 5000)) } while (nodestatus !== "waiting init") // get a seed for the node response = await makerequest('get', 'https //' + nodeapi + ' 8080/v1/genseed', {}, {}) seedphrase = response cipher seed mnemonic console log("got seed phrase "+seedphrase) // initialize the node console log("initializing wallet with password "+nodepassword) initbody = { wallet password buffer from(nodepassword) tostring('base64'), cipher seed mnemonic seedphrase, stateless init true } response = await makerequest('post', 'https //'+nodeapi+' 8080/v1/initwallet', initbody, {}) nodemacaroon = response admin macaroon console log("got node's macaroon "+nodemacaroon) // encrypt the macaroon and seed encryptedseed = crypto aes encrypt( buffer from(seedphrase join(",")) tostring('base64'), nodepassword ) tostring(); encryptedmacaroon = crypto aes encrypt( nodemacaroon, nodepassword ) tostring(); // backup seed and macaroon let macbody = { node id nodeid, macaroon encryptedmacaroon, name "admin" } response = await makerequest('post', 'https //api voltage cloud/organizations/' + orgid + '/node/macaroon', macbody, voltageheaders) console log("uploaded macaroon") let seedbackbody = { node id nodeid, seed encryptedseed } response = await makerequest('post', 'https //api voltage cloud/organizations/' + orgid + '/node/upload seed', seedbackbody, voltageheaders) console log("uploaded seed") console log("successfully created your node!") } function makerequest(method, url, data, headers) { return new promise(function (resolve, reject) { axios({ method method, url url, headers headers, data data }) then( (response) => { var result = response data resolve(result) }, (error) => { console log(error) reject(error) } ); }); } main()