GenSeed
GenSeed is the first method that should be used to instantiate a new lnd instance. This method allows a caller to generate a new aezeed cipher seed given an optional passphrase. If provided, the passphrase will be necessary to decrypt the cipherseed to expose the internal wallet seed.
Once the cipherseed is obtained and verified by the user, the InitWallet method should be used to commit the newly generated seed, and create the wallet.
Source: walletunlocker.proto
gRPC
rpc GenSeed (GenSeedRequest) returns (GenSeedResponse);
REST
HTTP Method | Path |
---|---|
GET | /v1/genseed |
Code Samples
- gRPC
- REST
- Shell
- Javascript
- Python
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:10009'
const TLS_PATH = 'LND_DIR/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync(['lightning.proto', 'walletunlocker.proto'], loaderOptions);
const lnrpc = grpc.loadPackageDefinition(packageDefinition).lnrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
let client = new lnrpc.WalletUnlocker(GRPC_HOST, sslCreds);
let request = {
aezeed_passphrase: <bytes>,
seed_entropy: <bytes>,
};
client.genSeed(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "cipher_seed_mnemonic": <string>,
// "enciphered_seed": <bytes>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the walletunlocker.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import walletunlocker_pb2 as lnrpc, walletunlocker_pb2_grpc as walletunlockerstub
GRPC_HOST = 'localhost:10009'
TLS_PATH = 'LND_DIR/tls.cert'
# create SSL credentials
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(TLS_PATH, 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
# make the request
channel = grpc.secure_channel(GRPC_HOST, ssl_creds)
stub = walletunlockerstub.WalletUnlockerStub(channel)
request = lnrpc.GenSeedRequest(
aezeed_passphrase=<bytes>,
seed_entropy=<bytes>,
)
response = stub.GenSeed(request)
print(response)
# {
# "cipher_seed_mnemonic": <string>,
# "enciphered_seed": <bytes>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8080'
let options = {
url: `https://${REST_HOST}/v1/genseed`,
// Work-around for self-signed certificates.
rejectUnauthorized: false,
json: true,
}
request.get(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// "cipher_seed_mnemonic": <array>, // <string>
// "enciphered_seed": <string>, // <bytes>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8080'
TLS_PATH = 'LND_DIR/tls.cert'
url = f'https://{REST_HOST}/v1/genseed'
r = requests.get(url, verify=TLS_PATH)
print(r.json())
# {
# "cipher_seed_mnemonic": <string>,
# "enciphered_seed": <bytes>,
# }
# There is no CLI command for this RPC
Messages
lnrpc.GenSeedRequest
Source: walletunlocker.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
aezeed_passphrase | bytes | string | query |
seed_entropy | bytes | string | query |
lnrpc.GenSeedResponse
Source: walletunlocker.proto
Field | gRPC Type | REST Type |
---|---|---|
cipher_seed_mnemonic | string[] | array |
enciphered_seed | bytes | string |