HDWallet

public class HDWallet : Wallet
extension HDWallet: Equatable
extension HDWallet: Hashable

A Tezos Wallet used for signing transactions before sending to the Tezos network. This object holds the public and private key used to create the contained Tezos address. You should NOT store a copy of this class in a singleton or gloabl variable of any kind. it should be created as needed and nil’d when not. In order to help developers achieve this, use the WalletCacheService to store/retreive an encrypted copy of the wallet on disk, and recreate the Wallet.

This wallet is a HD wallet, allowing the creation of many child wallets from the one base privateKey. It also follows the Bip39 stnadard for generation via a mnemonic.

Properties

  • The underlying wallet type, set to .hd

    Declaration

    Swift

    public let type: WalletType
  • The public TZ1 address of the wallet

    Declaration

    Swift

    public var address: String
  • An WalletCore object representing the PrivateKey used to generate the wallet

    Declaration

    Swift

    public var privateKey: PrivateKey
  • An WalletCore object representing the PublicKey used to generate the wallet address

    Declaration

    Swift

    public var publicKey: PublicKey
  • The Bip39 mnemonic used to generate the wallet

    Declaration

    Swift

    public var mnemonic: Mnemonic
  • The Bip44 derivationPath used to create the wallet

    Declaration

    Swift

    public var derivationPath: String

Init

  • Create a HDWallet by supplying a mnemonic string and a passphrase (or “” if none).

    Declaration

    Swift

    public init?(withMnemonic mnemonic: Mnemonic, passphrase: String, derivationPath: String = HD.defaultDerivationPath)

    Parameters

    withMnemonic

    A Mnemonic representing a BIP39 menmonic

    passphrase

    String contianing a passphrase, or empty string if none

    derivationPath

    Optional: use a different derivation path to the default HDWallet.defaultDerivationPath

  • Create a HDWallet by asking for a mnemonic of a given number of words and a passphrase (or “” if none).

    Declaration

    Swift

    public convenience init?(withMnemonicLength length: Mnemonic.NumberOfWords, passphrase: String, derivationPath: String = HD.defaultDerivationPath)

    Parameters

    withMnemonicLength

    Mnemonic.NumberOfWords the number of words to use when creating a mnemonic

    passphrase

    String contianing a passphrase, or empty string if none

    derivationPath

    Optional: use a different derivation path to the default HDWallet.defaultDerivationPath

Crypto Functions

  • Sign a hex payload with the private key

    Declaration

    Swift

    public func sign(_ hex: String, isOperation: Bool, completion: @escaping ((Result<[UInt8], KukaiError>) -> Void))
  • Return the curve used to create the key

    Declaration

    Swift

    public func privateKeyCurve() -> EllipticalCurve
  • Get a Base58 encoded version of the public key, in order to reveal the address on the network

    Declaration

    Swift

    public func publicKeyBase58encoded() -> String
  • The default implementation in Ledger is to not give users the option to provide their own derivation path, but instead increment the “account” field by 1 each time. This function will create a new HDWallet, by taking the default derivation path and changing the account to the index supplied, and using the same key

    Declaration

    Swift

    public func createChild(accountIndex: Int) -> HDWallet?
  • This function will create a new HDWallet, by using the same key combined with the supplied derivationPath

    Declaration

    Swift

    public func createChild(derivationPath: String) -> HDWallet?
  • Declaration

    Swift

    public static func == (lhs: HDWallet, rhs: HDWallet) -> Bool
  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)