Setting this parameter is not needed in the browser, but is required for NodeJS. This is a function which must submit a device or wallet password to the daemon for use in the next call. See showAuthPopup and the popup for implementation ideas. A function of this type must be specified in the constructor of BCJS in node, but in the browser it is ignored/optional. The call you are expected to make can be found in the source of: https://localhost.bc-vault.com:1991/PasswordInput?channelID=1&channelPasswordType=global
If the call was not successful, reject the promise. If it was, resolve it with no value.
The preAuthReference
object is passed from the preAuthWindowHandler
called previously.
This is a function which is called prior to authWindowHandler
and prepares it for use. In the browser this function is used to prime a popup window.
If the call was not successful, reject the promise. If it was, resolve it with a value you expect to be passed to authWindowHandler
.
This function is completely optional and can be left undefined.
The current state of the daemon, updated either manually or on device connect/disconnect after calling startObjectPolling
Get/Set token to be used for device actions
How long each auth grant will last in seconds since the last request.
The path to match the auth-token against. This is a security feature and allows you to fine tune access. Default is: undefined (don't check the full path, note: specifying this may require you to allow https://www.w3.org/TR/referrer-policy/#referrer-policy-origin-when-cross-origin on your webpage depending on which browsers you target)
Use cookies for session management. If set to false no cookies will be set and the session will be lost when 'authToken' is unloaded. It will need to be manually specified. It will be automatically refreshed if a request fails due to a token error.
Is BCData object polling already taking place?
Set Logging verbosity
Adds a status changed listener for updates to the BCData object
bc.AddBCDataChangedListener(console.log);
bc.triggerManualUpdate();
// => 1
// => 0
bc.AddBCDataChangedListener(console.log);
bc.triggerManualUpdate();
// => 1
// => 0
Copies a wallet private key to another walletType (in case of a fork etc.)
bc.CopyWalletToType(1,"BitCoin1","BcCash01","1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc").then(console.log)
// => "true"
await bc.CopyWalletToType(1,"BitCoin1","BcCash01","1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc")
// => true
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
publicAddress obtained from getWalletsOfType
true if operation was successful, otherwise will throw
Displays address on device for verification
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
publicAddress obtained from getWalletsOfType
true if display was successful, otherwise will throw
await bc.EnterGlobalPin(1)
DeviceID obtained from getDevices
Generates a new transaction on the device
var trxOptions = {from:"1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc",to:"1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc",feeCount:0,feePrice:"50000",amount:"500000000"};
bc.GenerateTransaction(1,"BitCoin1",trxOptions).then(console.log)
// generates a transaction of type bitCoinCash which uses 0.00050000 BCH as fee and sends 5 BCH back to the same address
var trxOptions = {from:"1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc",to:"1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc",feeCount:0,feePrice:"50000",amount:"500000000"};
await bc.GenerateTransaction(1,"BitCoin1",trxOptions)
// generates a transaction of type bitCoinCash which uses 0.00050000 BCH as fee and sends 5 BCH back to the same address
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
Transaction data object
Whether to broadcast the transaction to the blockchain automatically
The raw transaction hex prefixed with '0x' if operation was successful, otherwise will throw
Generates a new wallet on the device
bc.GenerateWallet(1,"BitCoin1").then(console.log)
// => "true"
await bc.GenerateWallet(1,"BitCoin1")
// => true
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
the public key of the new wallet
Signs data on the device
bc.SignData(1,bc.WalletType.ethereum,"0x9283099a29556fcf8fff5b2cea2d4f67cb7a7a8b","0x4920616d20627574206120737461636b2065786368616e676520706f7374").then(console.log)
// => "0x..."
await bc.SignData(1,bc.WalletType.ethereum,"0x9283099a29556fcf8fff5b2cea2d4f67cb7a7a8b","0x4920616d20627574206120737461636b2065786368616e676520706f7374")
// => "0x..."
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
publicAddress obtained from getWalletsOfType
Message data as a hex string prefixed with 0x
The raw signed message hex prefixed with '0x' if operation was successful, otherwise will throw
Gets a list of WalletTypes that are actually used on a specific device(have at least one wallet)
bc.getActiveWalletTypes(1).then(console.log)
// => ["BitCoin1","Ethereum"]
console.log(await bc.getActiveWalletTypes(1))
// => ["BitCoin1","Ethereum"]
DeviceID obtained from getDevices
An array containing requested data
Gets the available space on a specific device
bc.getAvailableSpace(1).then(console.log)
// => {"available":4294967295,"complete":4294967295}
console.log(await bc.getAvailableSpace(1))
// => {"available":4294967295,"complete":4294967295}
DeviceID obtained from getDevices
An object containing requested data, all numbers are in BYTES
Gets the requested data about wallets stored on the device. Details to query can be specified through the final parameter, which is set to query all details by default. Anything not queried will be filled with the empty value of that type, ie '' for strings and 0 for numbers.
bc.getBatchWalletDetails(1,"BitCoin1").then(console.log)
// => an array of type WalletBatchDataResponse
console.log(await bc.getBatchWalletDetails(1,"BitCoin1"))
// => an array of type WalletBatchDataResponse
DeviceID obtained from getDevices
WalletTypes obtained from getActiveWalletTypes or getSupportedWalletTypes
Query details flags, can be combined with binary OR
An array containing requested data
Gets an ID unique to each device. Will not persist device wipes and will change according to the HTTP Origin. This ID will persist reboots and requires global-pin authorization.
bc.getDeviceUID(1).then(console.log)
// => "0x9d8e1b33b93d7c27fb4fc17857e22fb529937947152ca7af441095949b20ba02"
console.log(await bc.getDeviceUID(1))
// => "0x9d8e1b33b93d7c27fb4fc17857e22fb529937947152ca7af441095949b20ba02"
DeviceID obtained from getDevices
The unique ID
console.log(await bc.getDevices())
// => [1,2]
An array of Device IDs of currently connected devices
Gets the firmware version of a specific device.
bc.getFirmwareVersion(1).then(console.log)
// => {"major":1,"minor":0,"revision":1,"date":{"day":17,"month":10,"year":2017},"apiVersion":{"major":1,"minor":0}}
console.log(await bc.getFirmwareVersion(1))
// => {"major":1,"minor":0,"revision":1,"date":{"day":17,"month":10,"year":2017},"apiVersion":{"major":1,"minor":0}}
DeviceID obtained from getDevices
An object containing requested data
Check if address is valid for a specific WalletType
bc.getIsAddressValid(1,"BitCoin1","1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc").then(console.log)
// => "true"
await bc.getIsAddressValid(1,"BitCoin1","1271DpdZ7iM6sXRasvjAQ6Hg2zw8bS3ADc")
// => true
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
publicAddress obtained from getWalletsOfType
true if address is valid
Gets the supported WalletTypes on a specific device
bc.getSupportedWalletTypes("BitCoin1").then(console.log)
// => [ "BitCoin1", "BcCash01", "Ethereum", "LiteCoi1", "Dash0001", ...]
console.log(await bc.getSupportedWalletTypes(1))
// => [ "BitCoin1", "BcCash01", "Ethereum", "LiteCoi1", "Dash0001", ...]
DeviceID obtained from getDevices
An array containing requested data
Gets the balance in currency-specific minimum units for the specified wallet from a web-service.
bc.getWalletBalance("BitCoin1","1PekCrsopzENYBa82YpmmBtJcsNgu4PqEV").then(console.log)
// => {"errorCode": 36864,"data": "0"}
console.log(await bc.getWalletBalance("BitCoin1","1PekCrsopzENYBa82YpmmBtJcsNgu4PqEV"))
// => {"errorCode": 36864,"data": "0"}
An object containing requested data
Returns WalletTypeInfo(name, ticker, etc...) for a specified WalletType if it exists
console.log(JSON.stringify(bc.getWalletTypeInfo(1)));
// => {"type":"BcCash01","name":"Bitcoin Cash","ticker":"BCH"}
console.log(JSON.stringify(bc.getWalletTypeInfo(1)));
// => {"type":"BcCash01","name":"Bitcoin Cash","ticker":"BCH"}
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
publicAddress obtained from getWalletsOfType
The UserData
DeviceID obtained from getDevices
WalletType obtained from getActiveWalletTypes or getSupportedWalletTypes
An array containing requested data
Starts polling daemon for changes and updates BCData object
bc.startObjectPolling(150);
//=> bc.BCData will now be updated if the getDevices array changes
bc.startObjectPolling(150);
//=> bc.BCData will now be updated if the getDevices array changes
how many milliseconds to wait between getDevices pings to daemon
Stops polling daemon for changes
bc.startObjectPolling(150);
bc.stopObjectPolling();
//=> bc.BCData will now not be updated if the getDevices array changes
bc.startObjectPolling(150);
bc.stopObjectPolling();
//=> bc.BCData will now not be updated if the getDevices array changes
Triggers a manual update to BCData.
console.log(JSON.stringify(bc.BCData));//Old
bc.triggerManualUpdate().then(function(){
console.log(JSON.stringify(bc.BCData));//Updated
});
console.log(JSON.stringify(bc.BCData));//Old
await bc.triggerManualUpdate();
console.log(JSON.stringify(bc.BCData));//Updated
Force an update or only update data if a new device connects or disconnects.
Generated using TypeDoc
The BCJS constructor.