Skip to main content

InitWallet

InitWallet is used when lnd is starting up for the first time to fully initialize the daemon and its internal wallet. At the very least a wallet password must be provided. This will be used to encrypt sensitive material on disk.

In the case of a recovery scenario, the user can also specify their aezeed mnemonic and passphrase. If set, then the daemon will use this prior state to initialize its internal wallet.

Alternatively, this can be used along with the GenSeed RPC to obtain a seed, then present it to the user. Once it has been verified by the user, the seed can be fed into this RPC in order to commit the new wallet.

Source: walletunlocker.proto

gRPC

rpc InitWallet (InitWalletRequest) returns (InitWalletResponse);

REST

HTTP MethodPath
POST /v1/initwallet

Code Samples

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 = {
wallet_password: <bytes>,
cipher_seed_mnemonic: <string>,
aezeed_passphrase: <bytes>,
recovery_window: <int32>,
channel_backups: <ChanBackupSnapshot>,
stateless_init: <bool>,
extended_master_key: <string>,
extended_master_key_birthday_timestamp: <uint64>,
watch_only: <WatchOnly>,
macaroon_root_key: <bytes>,
};
client.initWallet(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "admin_macaroon": <bytes>,
// }

Messages

lnrpc.InitWalletRequest

Source: walletunlocker.proto

FieldgRPC TypeREST TypeREST Placement
wallet_password
bytesstringbody
cipher_seed_mnemonic
string[]arraybody
aezeed_passphrase
bytesstringbody
recovery_window
int32integerbody
channel_backups
ChanBackupSnapshotobjectbody
stateless_init
boolbooleanbody
extended_master_key
stringstringbody
extended_master_key_birthday_timestamp
uint64stringbody
watch_only
WatchOnlyobjectbody
macaroon_root_key
bytesstringbody

lnrpc.InitWalletResponse

Source: walletunlocker.proto

FieldgRPC TypeREST Type
admin_macaroon
bytesstring

Nested Messages

lnrpc.ChanBackupSnapshot

FieldgRPC TypeREST Type
single_chan_backups
ChannelBackupsobject
multi_chan_backup
MultiChanBackupobject

lnrpc.ChannelBackup

FieldgRPC TypeREST Type
chan_point
ChannelPointobject
chan_backup
bytesstring

lnrpc.ChannelBackups

FieldgRPC TypeREST Type
chan_backups
ChannelBackup[]array

lnrpc.ChannelPoint

FieldgRPC TypeREST Type
funding_txid_bytes
bytesstring
funding_txid_str
stringstring
output_index
uint32integer

lnrpc.MultiChanBackup

FieldgRPC TypeREST Type
chan_points
ChannelPoint[]array
multi_chan_backup
bytesstring

lnrpc.WatchOnly

FieldgRPC TypeREST Type
master_key_birthday_timestamp
uint64string
master_key_fingerprint
bytesstring
accounts
WatchOnlyAccount[]array

lnrpc.WatchOnlyAccount

FieldgRPC TypeREST Type
purpose
uint32integer
coin_type
uint32integer
account
uint32integer
xpub
stringstring