Skip to main content

HDSigner

These are the HDSigner exported functions, the HDSigner is used to manage and sign transactions internally using your XPUB (HD wallets). BIP44/BIP84 are supported. P2WPKH, P2WSH, P2PKH, P2SH.

backup#

backup()#

Encrypt to password and backup to local storage for persistence.


createAccount#

createAccount()#

Create and derive a new account.


createKeypair#

createKeypair( addressIndex, isChange)#

Derives a bitcoinjs-lib key pair based on the address index and change marker provided.


deriveAccount#

deriveAccount( index )#

Derive a HD account based on the index number passed in.


deriveKeypair#

deriveKeypair( keypath )#

Takes an HD path and derives the key pair from it.


derivePubKey#

derivePubKey( keypath )#

Takes an HD path, derives a key pair from it and returns the public key.


getAccountXpub#

getAccountXpub()#

Gets the xPub for the account currently in use by the HDSigner, useful for public provider look-ups based on xPub accounts.


getAddressFromKeypair#

getAddressFromKeypair( keyPair )#

Takes a key pair and gives back a P2WPKH address.


getAddressFromPubKey#

getAddressFromPubKey( pubKey )#

Takes a public key and gives back a P2WPKH address.


getMasterFingerprint#

getMasterFingerprint()#

Get the master seed fingerprint used for signing bitcoinjs-lib PSBTs.


getNewChangeAddress#

getNewChangeAddress( skipIncrement )#

Get new address for sending change to.


getNewReceivingAddress#

getNewReceivingAddress( skipIncrement )#

Get new address for sending coins to.


getRootNode#

getRootNode()#

Returns the HDSigner's BIP32 root node.


restore#

restore( password )#

Restore on load from local storage and decrypt data to de-serialize objects.


setAccountIndex#

setAccountIndex( accountIndex )#

Set HD account based on accountIndex number passed in so HD indexes (change/receiving) will be updated accordingly to this account.


setLatestIndexesFromXPubTokens#

setLatestIndexesFromXPubTokens( tokens )#

Sets the change and receiving indexes from xPub tokens passed in, from a back-end provider response.


sign#

sign( res )#

Create signing information based on the HDSigner (if set)


signPSBT#

signPSBT( psbt, ownedIndexes )#

Signs a PSBT with xPub information from the HDSigner.