ssi.bitcoin.generateSync()
Callback type of generate
.
Syntax
window.ssi.bitcoin.generateSync(
options, // object
callback, // object
)
Parameters
options
object
. Direction about the key you want the user to generate.
passphrase(optional)
string
. The passphrase when generating a mnemonic (and a master key). This is optional whentype
is"mnemonic"
.path(optional)
string
. The Hierarchical Deterministic (HD) path: e.g."m/0'/1/2'"
. If null (or"m"
) a master key will be generated. The seed specified by the user as the primary will be used. This is required whentype
is"derivation"
.strength(optional)
number
. The strength when generating a mnemonic (and a master key). This is required whentype
is"mnemonic"
.type
BitcoinGenerateType
. The type that specifies the secret you want the user to generate: e.g."mnemonic"
,"derivation"
.
callback
object
. A reference to a function that should be called in the near future, when the result is returned. The callback function is passed two arguments — 1. Error object if failed otherwise null, 2. The resulting identifier.
error
Error
.identifier
string
.
Return value
None (undefined).
Examples
Generating mnemonic and master key in BIP-39
const callback = (error, pubkey) => {
if (error) {
throw new Error("Failed to generate mnemonic")
}
console.log(pubkey)
}
window.ssi.bitcoin.generateSync({type: "mnemonic", strength: 256}, callback)
// callback result
// "xpub661MyMwAqRbcEhXhghozukZbTsvY5HgocKwMHK2paDXsyVRKRysKfbR1Uvb618DFYUA1ZdrKeQWZ9cjkoPG7xzzs25PRs88EBXHHGiUeLF7"
This documentation is derived from window.ssi.type.ts in gecko-dev-for-ssi.