The Qi HD wallet is a BIP44-compliant hierarchical deterministic wallet used for managing a set of addresses in the Qi ledger. This is wallet implementation is the primary way to interact with the Qi UTXO ledger on the Quai network.
The Qi HD wallet supports:
AbstractHDWallet
<QiAddressInfo
>Property | Modifier | Type | Default value | Description |
---|---|---|---|---|
bip47HDNode | private | HDNodeWallet | undefined | The BIP47 HDNode instance used for deriving payment code addresses. This follows the BIP47 derivation path m/47’/969’/account’/0/index |
changeBip44 | private | Bip44QiWallet | undefined | The BIP44 wallet instance used for deriving change (sending) addresses. This follows the BIP44 derivation path m/44’/969’/account’/0/index |
externalBip44 | private | Bip44QiWallet | undefined | The BIP44 wallet instance used for deriving external (receiving) addresses. This follows the BIP44 derivation path m/44’/969’/account’/0/index |
paymentChannels | private | Map <string , PaymentChannel > | ... | Map of payment channels indexed by counterparty payment code |
privatekeyWallet | private | PrivatekeyQiWallet | undefined | The private key wallet instance used for deriving addresses from private keys. |
bip47derivationPath | private | string | "m/47'/969'" | The BIP47 derivation path m/47’/969’ |
Gets the payment codes for all open channels.
string
[]
The payment codes for all open channels.
Adds a new address to the wallet.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
addressIndex | number | The address index. |
The address info for the new address.
AbstractHDWallet.addAddress
Adds a new change address to the wallet.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
addressIndex | number | The address index. |
The address info for the new address.
Aggregates all the available UTXOs for the specified zone and account. This method creates a new transaction with all the available UTXOs as inputs and as fewest outputs as possible.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to aggregate the balance for. |
options ? | QiTransactionOptions | Optional transaction configuration. |
Promise
<TransactionResponse
>
The transaction response.
Checks if the specified address is used by querying the network node for the outpoints of the address. If the address is used, the outpoints are imported into the wallet.
Parameter | Type | Description |
---|---|---|
address | string | The address to check. |
Promise
<{
"isUsed"
: boolean
;
"outpoints"
: Outpoint
[];
}>
A promise that resolves to an object containing a boolean indicating whether the address is used and an array of outpoints.
If the query fails.
Connects the wallet to a provider and propagates the connection to all subwallets.
Parameter | Type | Description |
---|---|---|
provider | Provider | The provider. |
void
AbstractHDWallet.connect
Converts an amount of Qi to Quai and sends it to a specified Quai address.
Parameter | Type | Description |
---|---|---|
destinationAddress | string | The Quai address to send the converted Quai to. |
amount | bigint | The amount of Qi to convert to Quai. |
options ? | QiTransactionOptions | Optional transaction configuration. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
If the destination address is invalid, the amount is zero, or the conversion fails.
Locates the address information for the given address, searching through standard addresses, change addresses, and payment channel addresses.
Parameter | Type | Description |
---|---|---|
address | string | The address to locate. |
null
| QiAddressInfo
The address info or null if not found.
AbstractHDWallet.getAddressInfo
Gets the addresses for a given account.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
The addresses for the account.
AbstractHDWallet.getAddressesForAccount
Gets the addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The addresses for the zone.
AbstractHDWallet.getAddressesForZone
Gets the total balance for a specific zone by summing balances from all address types:
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to get the balance for |
Promise
<bigint
>
The total balance in the zone as a bigint
Gets a set of unused change addresses for transaction outputs and updates their status in the wallet. This method retrieves unused BIP44 change addresses, marks them as attempted use, and maintains the wallet’s address mapping state.
Parameter | Type | Default value | Description |
---|---|---|---|
count | number | undefined | The number of change addresses needed |
zone | Zone | undefined | The zone to get change addresses from |
account ? | number | 0 | The account index to use (defaults to 0). Default is 0 |
Promise
<string
[]>
A promise that resolves to an array of change addresses
Gets the change addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The change addresses for the zone.
Gets the gap addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The gap addresses for the zone.
Gets the gap change addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The gap change addresses for the zone.
Gets the gap payment channel addresses for the specified payment code.
Parameter | Type | Description |
---|---|---|
paymentCode | string | The payment code. |
zone | Zone | - |
The gap payment channel addresses for the payment code.
Gets all addresses that were imported via private keys.
Parameter | Type | Description |
---|---|---|
zone ? | Zone | Optional zone to filter addresses by |
Array of address info objects for imported addresses
Promise that resolves to the next address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
zone | Zone | The zone. |
Promise
<QiAddressInfo
>
The next Qi address information.
AbstractHDWallet.getNextAddress
Synchronously retrieves the next address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
zone | Zone | The zone. |
The next Qi address information.
AbstractHDWallet.getNextAddressSync
Promise that resolves to the next change address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The index of the account for which to retrieve the next change address. |
zone | Zone | The zone in which to retrieve the next change address. |
Promise
<QiAddressInfo
>
The next change neutered address information.
Synchronously retrieves the next change address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The index of the account for which to retrieve the next change address. |
zone | Zone | The zone in which to retrieve the next change address. |
The next change neutered address information.
Generates a payment address for receiving funds from the specified sender’s BIP47 payment code. Uses Diffie-Hellman key exchange to derive the address from the sender’s public key and receiver’s private key.
Parameter | Type | Default value | Description |
---|---|---|---|
senderPaymentCode | string | undefined | The Base58-encoded BIP47 payment code of the sender. |
zone | Zone | undefined | - |
account | number | 0 | - |
A promise that resolves to the payment address for receiving funds.
Throws an error if the payment code version is invalid.
Generates a payment address for sending funds to the specified receiver’s BIP47 payment code. Uses Diffie-Hellman key exchange to derive the address from the receiver’s public key and sender’s private key.
Parameter | Type | Default value | Description |
---|---|---|---|
receiverPaymentCode | string | undefined | The Base58-encoded BIP47 payment code of the receiver. |
zone | Zone | undefined | - |
account | number | 0 | - |
A promise that resolves to the payment address for sending funds.
Throws an error if the payment code version is invalid.
Gets the outpoints for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The outpoints for the zone.
Gets the payment channel addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
paymentCode | string | The payment code. |
zone | Zone | The zone. |
The payment channel addresses for the zone.
Creates a new BIP47 payment code for the specified account. The payment code is derived from the account’s BIP32 root key.
Parameter | Type | Default value | Description |
---|---|---|---|
account | number | 0 | The account index to derive the payment code from. |
string
A promise that resolves to the Base58-encoded BIP47 payment code.
Returns the private key for a given address. This method should be used with caution as it exposes the private key to the user.
Parameter | Type | Description |
---|---|---|
address | string | The address associated with the desired private key. |
string
The private key.
AbstractHDWallet.getPrivateKey
Retrieves the private key for a given transaction input.
This method derives the private key for a transaction input by locating the address info and then deriving the private key based on where the address info was found:
Parameter | Type | Description |
---|---|---|
input | TxInput | The transaction input containing the public key. |
string
The private key corresponding to the transaction input.
If the input does not contain a public key or if the address information cannot be found.
Gets a set of unused BIP44 addresses from the specified derivation path. It first checks if there are any unused addresses available in the _addressesMap and uses those if possible. If there are not enough unused addresses, it will generate new ones.
Parameter | Type | Description |
---|---|---|
amount | number | The number of addresses to get. |
account | number | - |
path | string | The derivation path to get addresses from. |
zone | Zone | The zone to get addresses from. |
An array of addresses.
Imports an array of outpoints into their corresponding wallets based on their derivation paths.
Parameter | Type | Description |
---|---|---|
outpoints | OutpointInfo [] | The outpoints to import. |
void
Imports a private key and adds it to the wallet.
Parameter | Type | Description |
---|---|---|
privateKey | string | The private key to import (hex string) |
Promise
<QiAddressInfo
>
The address information for the imported key
If the private key is invalid or the address is already in use
Receives a payment code and stores it in the wallet for future use. If the payment code is already in the wallet, it will be ignored.
Parameter | Type | Description |
---|---|---|
paymentCode | string | The payment code to store. |
void
Converts outpoints for a specific zone to UTXO format.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to filter outpoints for. |
UTXO
[]
An array of UTXO objects.
Prepares and sends a transaction with the specified parameters.
Parameter | Type | Description |
---|---|---|
amount | bigint | The amount of Qi to send. |
originZone | Zone | The zone where the transaction originates. |
getDestinationAddresses | (count ) => Promise <string []> | A function that returns a promise resolving to an array of destination addresses. |
coinSelectorCreator | (utxos ) => FewestCoinSelector | ConversionCoinSelector | - |
options | QiTransactionOptions | - |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
If provider is not set, insufficient balance, no available UTXOs, or insufficient spendable balance.
Prepares a fee estimation transaction with the specified parameters.
Parameter | Type | Description |
---|---|---|
selection | SelectedCoinsResult | The selected coins result. |
inputPubKeys | string [] | The public keys of the inputs. |
sendAddresses | string [] | The addresses to send to. |
changeAddresses | string [] | The addresses to change to. |
QiPerformActionTransaction
The prepared transaction.
Prepares a transaction with the specified parameters.
Parameter | Type | Description |
---|---|---|
selection | SelectedCoinsResult | The selected coins result. |
sendAddresses | string [] | The addresses to send to. |
changeAddresses | string [] | The addresses to change to. |
chainId | number | The chain ID. |
options | QiTransactionOptions | - |
Promise
<QiTransaction
>
A promise that resolves to the prepared transaction.
Scans the specified zone for addresses with unspent outputs. Starting at index 0, it will generate new addresses until the gap limit is reached for external and change BIP44 addresses and payment channel addresses.
Parameter | Type | Default value | Description |
---|---|---|---|
zone | Zone | undefined | The zone in which to scan for addresses. |
account ? | number | 0 | The index of the account to scan. Default is 0 |
Promise
<void
>
A promise that resolves when the scan is complete.
If the zone is invalid.
Sends a transaction to a specified recipient payment code in a specified zone.
Parameter | Type | Description |
---|---|---|
recipientPaymentCode | string | The payment code of the recipient. |
amount | bigint | The amount of Qi to send. |
originZone | Zone | The zone where the transaction originates. |
destinationZone | Zone | The zone where the transaction is sent. |
options ? | QiTransactionOptions | Optional transaction configuration. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
If the payment code is invalid, the amount is zero, or the zones are invalid.
Serializes the HD wallet state into a format suitable for storage or transmission.
An object representing the serialized state of the HD wallet, including outpoints, change addresses, gap addresses, and other inherited properties.
AbstractHDWallet.serialize
Sets the address use checker. The provided callback function should accept an address as input and return a boolean indicating whether the address is in use. If the callback returns true, the address is considered used and if it returns false, the address is considered unused.
Parameter | Type | Description |
---|---|---|
checker | AddressUsageCallback | The address use checker. |
void
Signs a message using the private key associated with the given address.
Parameter | Type | Description |
---|---|---|
address | string | The address for which the message is to be signed. |
message | string | Uint8Array | The message to be signed, either as a string or Uint8Array. |
Promise
<string
>
A promise that resolves to the signature of the message in hexadecimal string format.
AbstractHDWallet.signMessage
If the address does not correspond to a valid HD node or if signing fails.
Signs a Qi transaction and returns the serialized transaction.
Parameter | Type | Description |
---|---|---|
tx | QiTransactionRequest | The transaction to sign. |
Promise
<string
>
The serialized transaction.
AbstractHDWallet.signTransaction
If the UTXO transaction is invalid.
Scans the specified zone for addresses with unspent outputs. Starting at the last address index, it will generate new addresses until the gap limit is reached for external and change BIP44 addresses and payment channel addresses.
Parameter | Type | Default value | Description |
---|---|---|---|
zone | Zone | undefined | The zone in which to sync addresses. |
account ? | number | 0 | The index of the account to sync. Default is 0 |
onOutpointsCreated ? | OutpointsCallback | undefined | - |
onOutpointsDeleted ? | OutpointsCallback | undefined | - |
Promise
<void
>
A promise that resolves when the sync is complete.
If the zone is invalid.
Validates that the derivation path is either a BIP44 path or a valid payment code.
Parameter | Type | Description |
---|---|---|
path | string | The derivation path to validate |
isChange | boolean | Whether this is a change address |
void
If the path is invalid
Returns the extended public key of the root node of the BIP44 HD wallet.
string
The extended public key.
Creates a random HD wallet.
Type parameter |
---|
T extends AbstractHDWallet <NeuteredAddressInfo , T > |
Parameter | Type | Description |
---|---|---|
this | Object | The constructor of the HD wallet. |
password ? | string | The password. |
wordlist ? | Wordlist | The wordlist. |
T
The created instance.
AbstractHDWallet.createRandom
wallet/abstract-hdwallet.ts:195
Deserializes a serialized QiHDWallet object and reconstructs the wallet instance.
Parameter | Type | Description |
---|---|---|
serialized | SerializedQiHDWallet | The serialized object representing the state of a QiHDWallet. |
Promise
<QiHDWallet
>
A promise that resolves to a reconstructed QiHDWallet instance.
AbstractHDWallet.deserialize
If the serialized data is invalid or if any addresses in the gap addresses or gap change addresses do not exist in the wallet.
Creates an HD wallet from a mnemonic.
Type parameter |
---|
T extends AbstractHDWallet <NeuteredAddressInfo , T > |
Parameter | Type | Description |
---|---|---|
this | Object | The constructor of the HD wallet. |
mnemonic | Mnemonic | The mnemonic. |
T
The created instance.
AbstractHDWallet.fromMnemonic
wallet/abstract-hdwallet.ts:180
Creates an HD wallet from a phrase.
Type parameter |
---|
T extends AbstractHDWallet <NeuteredAddressInfo , T > |
Parameter | Type | Description |
---|---|---|
this | Object | The constructor of the HD wallet. |
phrase | string | The phrase. |
password ? | string | The password. |
wordlist ? | Wordlist | The wordlist. |
T
The created instance.
AbstractHDWallet.fromPhrase
wallet/abstract-hdwallet.ts:219
The Qi HD wallet is a BIP44-compliant hierarchical deterministic wallet used for managing a set of addresses in the Qi ledger. This is wallet implementation is the primary way to interact with the Qi UTXO ledger on the Quai network.
The Qi HD wallet supports:
AbstractHDWallet
<QiAddressInfo
>Property | Modifier | Type | Default value | Description |
---|---|---|---|---|
bip47HDNode | private | HDNodeWallet | undefined | The BIP47 HDNode instance used for deriving payment code addresses. This follows the BIP47 derivation path m/47’/969’/account’/0/index |
changeBip44 | private | Bip44QiWallet | undefined | The BIP44 wallet instance used for deriving change (sending) addresses. This follows the BIP44 derivation path m/44’/969’/account’/0/index |
externalBip44 | private | Bip44QiWallet | undefined | The BIP44 wallet instance used for deriving external (receiving) addresses. This follows the BIP44 derivation path m/44’/969’/account’/0/index |
paymentChannels | private | Map <string , PaymentChannel > | ... | Map of payment channels indexed by counterparty payment code |
privatekeyWallet | private | PrivatekeyQiWallet | undefined | The private key wallet instance used for deriving addresses from private keys. |
bip47derivationPath | private | string | "m/47'/969'" | The BIP47 derivation path m/47’/969’ |
Gets the payment codes for all open channels.
string
[]
The payment codes for all open channels.
Adds a new address to the wallet.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
addressIndex | number | The address index. |
The address info for the new address.
AbstractHDWallet.addAddress
Adds a new change address to the wallet.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
addressIndex | number | The address index. |
The address info for the new address.
Aggregates all the available UTXOs for the specified zone and account. This method creates a new transaction with all the available UTXOs as inputs and as fewest outputs as possible.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to aggregate the balance for. |
options ? | QiTransactionOptions | Optional transaction configuration. |
Promise
<TransactionResponse
>
The transaction response.
Checks if the specified address is used by querying the network node for the outpoints of the address. If the address is used, the outpoints are imported into the wallet.
Parameter | Type | Description |
---|---|---|
address | string | The address to check. |
Promise
<{
"isUsed"
: boolean
;
"outpoints"
: Outpoint
[];
}>
A promise that resolves to an object containing a boolean indicating whether the address is used and an array of outpoints.
If the query fails.
Connects the wallet to a provider and propagates the connection to all subwallets.
Parameter | Type | Description |
---|---|---|
provider | Provider | The provider. |
void
AbstractHDWallet.connect
Converts an amount of Qi to Quai and sends it to a specified Quai address.
Parameter | Type | Description |
---|---|---|
destinationAddress | string | The Quai address to send the converted Quai to. |
amount | bigint | The amount of Qi to convert to Quai. |
options ? | QiTransactionOptions | Optional transaction configuration. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
If the destination address is invalid, the amount is zero, or the conversion fails.
Locates the address information for the given address, searching through standard addresses, change addresses, and payment channel addresses.
Parameter | Type | Description |
---|---|---|
address | string | The address to locate. |
null
| QiAddressInfo
The address info or null if not found.
AbstractHDWallet.getAddressInfo
Gets the addresses for a given account.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
The addresses for the account.
AbstractHDWallet.getAddressesForAccount
Gets the addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The addresses for the zone.
AbstractHDWallet.getAddressesForZone
Gets the total balance for a specific zone by summing balances from all address types:
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to get the balance for |
Promise
<bigint
>
The total balance in the zone as a bigint
Gets a set of unused change addresses for transaction outputs and updates their status in the wallet. This method retrieves unused BIP44 change addresses, marks them as attempted use, and maintains the wallet’s address mapping state.
Parameter | Type | Default value | Description |
---|---|---|---|
count | number | undefined | The number of change addresses needed |
zone | Zone | undefined | The zone to get change addresses from |
account ? | number | 0 | The account index to use (defaults to 0). Default is 0 |
Promise
<string
[]>
A promise that resolves to an array of change addresses
Gets the change addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The change addresses for the zone.
Gets the gap addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The gap addresses for the zone.
Gets the gap change addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The gap change addresses for the zone.
Gets the gap payment channel addresses for the specified payment code.
Parameter | Type | Description |
---|---|---|
paymentCode | string | The payment code. |
zone | Zone | - |
The gap payment channel addresses for the payment code.
Gets all addresses that were imported via private keys.
Parameter | Type | Description |
---|---|---|
zone ? | Zone | Optional zone to filter addresses by |
Array of address info objects for imported addresses
Promise that resolves to the next address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
zone | Zone | The zone. |
Promise
<QiAddressInfo
>
The next Qi address information.
AbstractHDWallet.getNextAddress
Synchronously retrieves the next address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The account number. |
zone | Zone | The zone. |
The next Qi address information.
AbstractHDWallet.getNextAddressSync
Promise that resolves to the next change address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The index of the account for which to retrieve the next change address. |
zone | Zone | The zone in which to retrieve the next change address. |
Promise
<QiAddressInfo
>
The next change neutered address information.
Synchronously retrieves the next change address for the specified account and zone.
Parameter | Type | Description |
---|---|---|
account | number | The index of the account for which to retrieve the next change address. |
zone | Zone | The zone in which to retrieve the next change address. |
The next change neutered address information.
Generates a payment address for receiving funds from the specified sender’s BIP47 payment code. Uses Diffie-Hellman key exchange to derive the address from the sender’s public key and receiver’s private key.
Parameter | Type | Default value | Description |
---|---|---|---|
senderPaymentCode | string | undefined | The Base58-encoded BIP47 payment code of the sender. |
zone | Zone | undefined | - |
account | number | 0 | - |
A promise that resolves to the payment address for receiving funds.
Throws an error if the payment code version is invalid.
Generates a payment address for sending funds to the specified receiver’s BIP47 payment code. Uses Diffie-Hellman key exchange to derive the address from the receiver’s public key and sender’s private key.
Parameter | Type | Default value | Description |
---|---|---|---|
receiverPaymentCode | string | undefined | The Base58-encoded BIP47 payment code of the receiver. |
zone | Zone | undefined | - |
account | number | 0 | - |
A promise that resolves to the payment address for sending funds.
Throws an error if the payment code version is invalid.
Gets the outpoints for the specified zone.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone. |
The outpoints for the zone.
Gets the payment channel addresses for the specified zone.
Parameter | Type | Description |
---|---|---|
paymentCode | string | The payment code. |
zone | Zone | The zone. |
The payment channel addresses for the zone.
Creates a new BIP47 payment code for the specified account. The payment code is derived from the account’s BIP32 root key.
Parameter | Type | Default value | Description |
---|---|---|---|
account | number | 0 | The account index to derive the payment code from. |
string
A promise that resolves to the Base58-encoded BIP47 payment code.
Returns the private key for a given address. This method should be used with caution as it exposes the private key to the user.
Parameter | Type | Description |
---|---|---|
address | string | The address associated with the desired private key. |
string
The private key.
AbstractHDWallet.getPrivateKey
Retrieves the private key for a given transaction input.
This method derives the private key for a transaction input by locating the address info and then deriving the private key based on where the address info was found:
Parameter | Type | Description |
---|---|---|
input | TxInput | The transaction input containing the public key. |
string
The private key corresponding to the transaction input.
If the input does not contain a public key or if the address information cannot be found.
Gets a set of unused BIP44 addresses from the specified derivation path. It first checks if there are any unused addresses available in the _addressesMap and uses those if possible. If there are not enough unused addresses, it will generate new ones.
Parameter | Type | Description |
---|---|---|
amount | number | The number of addresses to get. |
account | number | - |
path | string | The derivation path to get addresses from. |
zone | Zone | The zone to get addresses from. |
An array of addresses.
Imports an array of outpoints into their corresponding wallets based on their derivation paths.
Parameter | Type | Description |
---|---|---|
outpoints | OutpointInfo [] | The outpoints to import. |
void
Imports a private key and adds it to the wallet.
Parameter | Type | Description |
---|---|---|
privateKey | string | The private key to import (hex string) |
Promise
<QiAddressInfo
>
The address information for the imported key
If the private key is invalid or the address is already in use
Receives a payment code and stores it in the wallet for future use. If the payment code is already in the wallet, it will be ignored.
Parameter | Type | Description |
---|---|---|
paymentCode | string | The payment code to store. |
void
Converts outpoints for a specific zone to UTXO format.
Parameter | Type | Description |
---|---|---|
zone | Zone | The zone to filter outpoints for. |
UTXO
[]
An array of UTXO objects.
Prepares and sends a transaction with the specified parameters.
Parameter | Type | Description |
---|---|---|
amount | bigint | The amount of Qi to send. |
originZone | Zone | The zone where the transaction originates. |
getDestinationAddresses | (count ) => Promise <string []> | A function that returns a promise resolving to an array of destination addresses. |
coinSelectorCreator | (utxos ) => FewestCoinSelector | ConversionCoinSelector | - |
options | QiTransactionOptions | - |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
If provider is not set, insufficient balance, no available UTXOs, or insufficient spendable balance.
Prepares a fee estimation transaction with the specified parameters.
Parameter | Type | Description |
---|---|---|
selection | SelectedCoinsResult | The selected coins result. |
inputPubKeys | string [] | The public keys of the inputs. |
sendAddresses | string [] | The addresses to send to. |
changeAddresses | string [] | The addresses to change to. |
QiPerformActionTransaction
The prepared transaction.
Prepares a transaction with the specified parameters.
Parameter | Type | Description |
---|---|---|
selection | SelectedCoinsResult | The selected coins result. |
sendAddresses | string [] | The addresses to send to. |
changeAddresses | string [] | The addresses to change to. |
chainId | number | The chain ID. |
options | QiTransactionOptions | - |
Promise
<QiTransaction
>
A promise that resolves to the prepared transaction.
Scans the specified zone for addresses with unspent outputs. Starting at index 0, it will generate new addresses until the gap limit is reached for external and change BIP44 addresses and payment channel addresses.
Parameter | Type | Default value | Description |
---|---|---|---|
zone | Zone | undefined | The zone in which to scan for addresses. |
account ? | number | 0 | The index of the account to scan. Default is 0 |
Promise
<void
>
A promise that resolves when the scan is complete.
If the zone is invalid.
Sends a transaction to a specified recipient payment code in a specified zone.
Parameter | Type | Description |
---|---|---|
recipientPaymentCode | string | The payment code of the recipient. |
amount | bigint | The amount of Qi to send. |
originZone | Zone | The zone where the transaction originates. |
destinationZone | Zone | The zone where the transaction is sent. |
options ? | QiTransactionOptions | Optional transaction configuration. |
Promise
<TransactionResponse
>
A promise that resolves to the transaction response.
If the payment code is invalid, the amount is zero, or the zones are invalid.
Serializes the HD wallet state into a format suitable for storage or transmission.
An object representing the serialized state of the HD wallet, including outpoints, change addresses, gap addresses, and other inherited properties.
AbstractHDWallet.serialize
Sets the address use checker. The provided callback function should accept an address as input and return a boolean indicating whether the address is in use. If the callback returns true, the address is considered used and if it returns false, the address is considered unused.
Parameter | Type | Description |
---|---|---|
checker | AddressUsageCallback | The address use checker. |
void
Signs a message using the private key associated with the given address.
Parameter | Type | Description |
---|---|---|
address | string | The address for which the message is to be signed. |
message | string | Uint8Array | The message to be signed, either as a string or Uint8Array. |
Promise
<string
>
A promise that resolves to the signature of the message in hexadecimal string format.
AbstractHDWallet.signMessage
If the address does not correspond to a valid HD node or if signing fails.
Signs a Qi transaction and returns the serialized transaction.
Parameter | Type | Description |
---|---|---|
tx | QiTransactionRequest | The transaction to sign. |
Promise
<string
>
The serialized transaction.
AbstractHDWallet.signTransaction
If the UTXO transaction is invalid.
Scans the specified zone for addresses with unspent outputs. Starting at the last address index, it will generate new addresses until the gap limit is reached for external and change BIP44 addresses and payment channel addresses.
Parameter | Type | Default value | Description |
---|---|---|---|
zone | Zone | undefined | The zone in which to sync addresses. |
account ? | number | 0 | The index of the account to sync. Default is 0 |
onOutpointsCreated ? | OutpointsCallback | undefined | - |
onOutpointsDeleted ? | OutpointsCallback | undefined | - |
Promise
<void
>
A promise that resolves when the sync is complete.
If the zone is invalid.
Validates that the derivation path is either a BIP44 path or a valid payment code.
Parameter | Type | Description |
---|---|---|
path | string | The derivation path to validate |
isChange | boolean | Whether this is a change address |
void
If the path is invalid
Returns the extended public key of the root node of the BIP44 HD wallet.
string
The extended public key.
Creates a random HD wallet.
Type parameter |
---|
T extends AbstractHDWallet <NeuteredAddressInfo , T > |
Parameter | Type | Description |
---|---|---|
this | Object | The constructor of the HD wallet. |
password ? | string | The password. |
wordlist ? | Wordlist | The wordlist. |
T
The created instance.
AbstractHDWallet.createRandom
wallet/abstract-hdwallet.ts:195
Deserializes a serialized QiHDWallet object and reconstructs the wallet instance.
Parameter | Type | Description |
---|---|---|
serialized | SerializedQiHDWallet | The serialized object representing the state of a QiHDWallet. |
Promise
<QiHDWallet
>
A promise that resolves to a reconstructed QiHDWallet instance.
AbstractHDWallet.deserialize
If the serialized data is invalid or if any addresses in the gap addresses or gap change addresses do not exist in the wallet.
Creates an HD wallet from a mnemonic.
Type parameter |
---|
T extends AbstractHDWallet <NeuteredAddressInfo , T > |
Parameter | Type | Description |
---|---|---|
this | Object | The constructor of the HD wallet. |
mnemonic | Mnemonic | The mnemonic. |
T
The created instance.
AbstractHDWallet.fromMnemonic
wallet/abstract-hdwallet.ts:180
Creates an HD wallet from a phrase.
Type parameter |
---|
T extends AbstractHDWallet <NeuteredAddressInfo , T > |
Parameter | Type | Description |
---|---|---|
this | Object | The constructor of the HD wallet. |
phrase | string | The phrase. |
password ? | string | The password. |
wordlist ? | Wordlist | The wordlist. |
T
The created instance.
AbstractHDWallet.fromPhrase
wallet/abstract-hdwallet.ts:219