List of events

Last updated last month

Event bus provides a way to subscribe to events from any of the services running.

const eventBus = require('ocore/event_bus.js');

Wallet is ready (only headless wallet)

Headless wallet is needed for bots that hold private keys and can send transactions. This event is emitted when passphrase has been entered by bot admin and single wallet is loaded. Before that event, bot outputs device address, device pubkey and pairing key.

eventBus.on('headless_wallet_ready', () => {
});

Start database update

This event is emitted when bot executes series database queries to upgrade the database to new version.

eventBus.on('started_db_upgrade', () => {
});

End of database update

This event is emitted when bot finishes database upgrade.

eventBus.on('finished_db_upgrade', () => {
});

Connection to the hub via ws is established

eventBus.on('connected', () => {
});

Connection to the hub is established and an error is possible

The url parameter is protocol + domain + path (for example: wss://byteball.org/bb).

eventBus.on('open-' + url, (error) => {
});

Connected to ws

eventBus.on('connected_to_source', (new_ws) => {
});

Not a fatal error

eventBus.on('nonfatal_error', (msg, Error) => {
});

Unit validation status

eventBus.on("validated-" + unit, (bValid) => {
});

New joint

eventBus.on('new_joint', (objJoint) => {
});

Main chain index has become stable

eventBus.on('mci_became_stable', (mci) => {
});

New unstable transactions

eventBus.on('new_my_transactions', (arrNewUnits) => {
});

Stable transactions

eventBus.on('my_transactions_became_stable', (arrUnits) => {
});

Changes with addresses leading to possible new transactions

eventBus.on('maybe_new_transactions', () => {
});

New unstable unit

eventBus.on("new_my_unit-" + unit, (objJoint) => {
});

New private payment

eventBus.on("received_payment", (payer_device_address, assocAmountsByAsset, asset, message_counter, bToSharedAddress) => {
});

Stable unit

eventBus.on('my_stable-' + unit , () => {
});

Catching up done

eventBus.on('catching_up_done' , () => {
});

Catching up started

eventBus.on('catching_up_started' , () => {
});

Catchup next hash tree

eventBus.on('catchup_next_hash_tree' , () => {
});

New direct private chains

eventBus.on('new_direct_private_chains' , (arrChains) => {
});

Unhandled private payments left

eventBus.on('unhandled_private_payments_left' , (rowsLength) => {
});

Version of the connected user

eventBus.on('peer_version', (ws, body) => {
});

New wallet version available

This event is emitted when Hub sends message about new wallet version.

eventBus.on('new_version', (ws, body) => {
});

Received the project number for notifications on the phone

eventBus.on('receivedPushProjectNumber', (ws, body) => {
});

Client logged in

eventBus.on('client_logged_in', (ws) => {
});

Message from the hub

eventBus.on("message_from_hub", (ws, subject, body) => {
});

Message for light client

eventBus.on("message_for_light", (ws, subject, body) => {
});

Exchange rates are updated

This event is emitted when wallet updated rates that they got from Hub.

eventBus.on("rates_updated", () => {
});

Message received by hub

eventBus.on('peer_sent_new_message', (ws, objDeviceMessage) => {
});

Notifications are enabled

eventBus.on("enableNotification", (device_address, params) => {
});

Notifications are disabled

eventBus.on("disableNotification", (device_address, params) => {
});

Create new wallet

eventBus.on("create_new_wallet", (walletId, wallet_definition_template, arrDeviceAddresses, wallet_name, other_cosigners, is_single_address) => {
});

Wallet created and signed

eventBus.on('wallet_completed', (walletId) => {
});

Wallet was rejected by the other side

eventBus.on('wallet_declined', (wallet, rejector_device_address) => {
});

Wallet has been confirmed by the other party

eventBus.on('wallet_approved', (wallet, device_address) => {
});

Created new address

eventBus.on('new_wallet_address', (address) => {
});

Created new address

eventBus.on("new_address-" + address, () => {
});

Unit saved

eventBus.on('saved_unit-' + unit, (objJoint) => {
});

Attempt to pair us with another correspondent

This event is emitted when there is a pairing attempt, this enables bot to decide with the code if the pairing code is valid or not. If you would like to accept any pairing code then there is easier solution.

eventBus.on("pairing_attempt", (from_address, pairing_secret) => {
if (pairing_secret == "SOME_SECRET") {
eventBus.emit("paired", from_address, pairing_secret);
}
});

Pairing was successful

This event is emitted on successful pairing (also when user removed and re-added the bot).

eventBus.on("paired", (from_address, pairing_secret) => {
let device = require('byteballcore/device.js');
// say hi to anyone who pair with bot
device.sendMessageToDevice(from_address, 'text', 'Hi!');
});

Pairing was successful using pairing secret

eventBus.on('paired_by_secret-' + body, (from_address) => {
});

The paired device has been removed

eventBus.on("removed_paired_device", (from_address) => {
});

History update started

eventBus.on('refresh_light_started', () => {
});

History update finished

eventBus.on('refresh_light_done', () => {
});

A new message string type message has been received

This event is emitted when text message is received by bot.

eventBus.on("text", (from_address, body, message_counter) => {
let device = require('byteballcore/device.js');
// echo back same message
device.sendMessageToDevice(from_address, 'text', 'ECHO: '+ body);
});

A new message object type message has been received

This event is emitted when object message is received by bot.

eventBus.on("object", (from_address, body, message_counter) => {
});

Change in permission to store message history

eventBus.on("chat_recording_pref", (from_address, body, message_counter) => {
});

Created a new shared address

eventBus.on("create_new_shared_address", (address_definition_template, assocMemberDeviceAddressesBySigningPaths) => {
});

Signing request

eventBus.on("signing_request", (objAddress, address, objUnit, assocPrivatePayloads, from_address, signing_path) => {
});

Signed event

eventBus.on("signature-" + device_address + "-" + address + "-" + signing_path + "-" + buf_to_sign.toString("base64"), (sig) => {
});

Refuse to sign

eventBus.on('refused_to_sign', (device_address) => {
});

Confirmed on another device

eventBus.on('confirm_on_other_devices', () => {
});

All private payments are processed

eventBus.on('all_private_payments_handled', (from_address) => {
});

All private payments are processed in a unit

eventBus.on('all_private_payments_handled-' + first_chain_unit, () => {
});

Event for custom Request

You can add your own communication protocol on top of the Byteball one. See Request example there.

const network = require('byteballcore/network.js');
eventBus.on('custom_request', function(ws, params, tag) {
var response = 'put response here';
return network.sendResponse(ws, tag, response);
}

Event for custom JustSaying

You can add your own communication protocol on top of the Byteball one. See JustSaying example there.

eventBus.on('custom_justsaying', function(ws, content) {
};

Database is read and ready to work (only Cordova)

eventEmitter.once('ready', () => {
console.log("db is now ready");
});

Error sending message via ws

ws.on('error', (error) => {
});
Contents
Wallet is ready (only headless wallet)Start database updateEnd of database updateConnection to the hub via ws is establishedConnection to the hub is established and an error is possibleConnected to wsNot a fatal errorUnit validation statusNew jointMain chain index has become stableNew unstable transactionsStable transactionsChanges with addresses leading to possible new transactionsNew unstable unitNew private paymentStable unitCatching up doneCatching up startedCatchup next hash treeNew direct private chainsUnhandled private payments leftVersion of the connected userNew wallet version availableReceived the project number for notifications on the phoneClient logged inMessage from the hubMessage for light clientExchange rates are updatedMessage received by hubNotifications are enabledNotifications are disabledCreate new walletWallet created and signedWallet was rejected by the other sideWallet has been confirmed by the other partyCreated new addressCreated new addressUnit savedAttempt to pair us with another correspondentPairing was successfulPairing was successful using pairing secretThe paired device has been removedHistory update startedHistory update finishedA new message string type message has been receivedA new message object type message has been received Change in permission to store message historyCreated a new shared addressSigning requestSigned eventRefuse to signConfirmed on another deviceAll private payments are processedAll private payments are processed in a unitEvent for custom RequestEvent for custom JustSayingDatabase is read and ready to work (only Cordova)Error sending message via ws