Events list
Event bus provides a way to subscribe to events from any of the services running.
1
const eventBus = require('ocore/event_bus.js');
Copied!

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.
1
eventBus.on('headless_wallet_ready', () => {
2
3
});
Copied!

Start database update

This event is emitted when bot executes series database queries to upgrade the database to new version.
1
eventBus.on('started_db_upgrade', () => {
2
3
});
Copied!

End of database update

This event is emitted when bot finishes database upgrade.
1
eventBus.on('finished_db_upgrade', () => {
2
3
});
Copied!

Connection to the hub via ws is established

1
eventBus.on('connected', () => {
2
3
});
Copied!

Connection to the hub is established and an error is possible

The url parameter is protocol + domain + path (for example: wss://obyte.org/bb).
1
eventBus.on('open-' + url, (error) => {
2
3
});
Copied!

Connected to ws

1
eventBus.on('connected_to_source', (new_ws) => {
2
3
});
Copied!

Not a fatal error

1
eventBus.on('nonfatal_error', (msg, Error) => {
2
3
});
Copied!

Unit validation status

1
eventBus.on("validated-" + unit, (bValid) => {
2
3
});
Copied!

New joint

1
eventBus.on('new_joint', (objJoint) => {
2
3
});
Copied!

Main chain index has become stable

1
eventBus.on('mci_became_stable', (mci) => {
2
3
});
Copied!

New unstable transactions

1
eventBus.on('new_my_transactions', (arrNewUnits) => {
2
3
});
Copied!

Stable transactions

1
eventBus.on('my_transactions_became_stable', (arrUnits) => {
2
3
});
Copied!

Bad transactions

1
eventBus.on('sequence_became_bad', (arrUniqueUnits) => {
2
3
});
Copied!

First history received

1
eventBus.on('first_history_received', () => {
2
3
});
Copied!

Changes with addresses leading to possible new transactions

1
eventBus.on('maybe_new_transactions', () => {
2
3
});
Copied!

New unstable unit

1
eventBus.on("new_my_unit-" + unit, (objJoint) => {
2
3
});
Copied!

New private payment

1
eventBus.on("received_payment", (payer_device_address, assocAmountsByAsset, asset, message_counter, bToSharedAddress) => {
2
3
});
Copied!

Stable unit

1
eventBus.on('my_stable-' + unit , () => {
2
3
});
Copied!

Syncing is idle

1
eventBus.on('sync_idle' , () => {
2
3
});
Copied!

Catching up done

1
eventBus.on('catching_up_done' , () => {
2
3
});
Copied!

Catching up started

1
eventBus.on('catching_up_started' , () => {
2
3
});
Copied!

Catchup next hash tree

1
eventBus.on('catchup_next_hash_tree' , () => {
2
3
});
Copied!

New direct private chains

1
eventBus.on('new_direct_private_chains' , (arrChains) => {
2
3
});
Copied!

Unhandled private payments left

1
eventBus.on('unhandled_private_payments_left' , (rowsLength) => {
2
3
});
Copied!

Version of the connected user

1
eventBus.on('peer_version', (ws, body) => {
2
3
});
Copied!

New wallet version available

This event is emitted when Hub sends message about new wallet version.
1
eventBus.on('new_version', (ws, body) => {
2
3
});
Copied!

Received the project number for notifications on the phone

1
eventBus.on('receivedPushProjectNumber', (ws, body) => {
2
3
});
Copied!

Client logged in

1
eventBus.on('client_logged_in', (ws) => {
2
3
});
Copied!

Message from the hub

1
eventBus.on("message_from_hub", (ws, subject, body) => {
2
3
});
Copied!

Message for light client

1
eventBus.on("message_for_light", (ws, subject, body) => {
2
3
});
Copied!

Exchange rates are updated

This event is emitted when wallet updated rates that they got from Hub.
1
const network = require('ocore/network.js');
2
eventBus.on("rates_updated", () => {
3
console.log(JSON.stringify(network.exchangeRates, null, 2));
4
});
Copied!

Message received by hub

1
eventBus.on('peer_sent_new_message', (ws, objDeviceMessage) => {
2
3
});
Copied!

Notifications are enabled

1
eventBus.on("enableNotification", (device_address, params) => {
2
3
});
Copied!

Notifications are disabled

1
eventBus.on("disableNotification", (device_address, params) => {
2
3
});
Copied!

Create new wallet

1
eventBus.on("create_new_wallet", (walletId, wallet_definition_template, arrDeviceAddresses, wallet_name, other_cosigners, is_single_address) => {
2
3
});
Copied!

Wallet created and signed

1
eventBus.on('wallet_completed', (walletId) => {
2
3
});
Copied!

Wallet was rejected by the other side

1
eventBus.on('wallet_declined', (wallet, rejector_device_address) => {
2
3
});
Copied!

Wallet has been confirmed by the other party

1
eventBus.on('wallet_approved', (wallet, device_address) => {
2
3
});
Copied!

Created new address

1
eventBus.on('new_wallet_address', (address) => {
2
3
});
Copied!

Created new address

1
eventBus.on("new_address-" + address, () => {
2
3
});
Copied!

Unit saved

1
eventBus.on('saved_unit-' + unit, (objJoint) => {
2
3
});
Copied!

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.
1
eventBus.on("pairing_attempt", (from_address, pairing_secret) => {
2
if (pairing_secret == "SOME_SECRET") {
3
eventBus.emit("paired", from_address, pairing_secret);
4
}
5
});
Copied!

Pairing was successful

This event is emitted on successful pairing (also when user removed and re-added the bot).
1
eventBus.on("paired", (from_address, pairing_secret) => {
2
let device = require('ocore/device.js');
3
// say hi to anyone who pair with bot
4
device.sendMessageToDevice(from_address, 'text', 'Hi!');
5
});
Copied!

Pairing was successful using pairing secret

1
eventBus.on('paired_by_secret-' + body, (from_address) => {
2
3
});
Copied!

The paired device has been removed

1
eventBus.on("removed_paired_device", (from_address) => {
2
3
});
Copied!

History update started

1
eventBus.on('refresh_light_started', () => {
2
3
});
Copied!

History update finished

1
eventBus.on('refresh_light_done', () => {
2
3
});
Copied!

A new message string type message has been received

This event is emitted when text message is received by bot.
1
eventBus.on("text", (from_address, body, message_counter) => {
2
let device = require('ocore/device.js');
3
// echo back the same message
4
device.sendMessageToDevice(from_address, 'text', 'ECHO: '+ body);
5
});
Copied!

A new message object type message has been received

This event is emitted when object message is received by bot.
1
eventBus.on("object", (from_address, body, message_counter) => {
2
let device = require('ocore/device.js');
3
// echo back the same object back
4
device.sendMessageToDevice(from_address, 'object', body);
5
});
Copied!

Change in permission to store message history

1
eventBus.on("chat_recording_pref", (from_address, body, message_counter) => {
2
3
});
Copied!

Created a new shared address

1
eventBus.on("create_new_shared_address", (address_definition_template, assocMemberDeviceAddressesBySigningPaths) => {
2
3
});
Copied!

Signing request

1
eventBus.on("signing_request", (objAddress, address, objUnit, assocPrivatePayloads, from_address, signing_path) => {
2
3
});
Copied!

Signed event

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

Refuse to sign

1
eventBus.on('refused_to_sign', (device_address) => {
2
3
});
Copied!

Confirmed on another device

1
eventBus.on('confirm_on_other_devices', () => {
2
3
});
Copied!

All private payments are processed

1
eventBus.on('all_private_payments_handled', (from_address) => {
2
3
});
Copied!

All private payments are processed in a unit

1
eventBus.on('all_private_payments_handled-' + first_chain_unit, () => {
2
3
});
Copied!

Event for custom Request

You can add your own communication protocol on top of the Obyte one. See Request example there.
1
const network = require('ocore/network.js');
2
3
eventBus.on('custom_request', function(ws, params, tag) {
4
var response = 'put response here';
5
return network.sendResponse(ws, tag, response);
6
}
Copied!

Event for custom JustSaying

You can add your own communication protocol on top of the Obyte one. See JustSaying example there.
1
eventBus.on('custom_justsaying', function(ws, content) {
2
3
};
Copied!

Database is read and ready to work (only Cordova)

1
eventEmitter.once('ready', () => {
2
console.log("db is now ready");
3
});
Copied!

Error sending message via ws

1
ws.on('error', (error) => {
2
3
});
Copied!
Last modified 25d ago
Export as PDF
Copy link
Edit on GitHub
Contents
Wallet is ready (only headless wallet)
Start database update
End of database update
Connection to the hub via ws is established
Connection to the hub is established and an error is possible
Connected to ws
Not a fatal error
Unit validation status
New joint
Main chain index has become stable
New unstable transactions
Stable transactions
Bad transactions
First history received
Changes with addresses leading to possible new transactions
New unstable unit
New private payment
Stable unit
Syncing is idle
Catching up done
Catching up started
Catchup next hash tree
New direct private chains
Unhandled private payments left
Version of the connected user
New wallet version available
Received the project number for notifications on the phone
Client logged in
Message from the hub
Message for light client
Exchange rates are updated
Message received by hub
Notifications are enabled
Notifications are disabled
Create new wallet
Wallet created and signed
Wallet was rejected by the other side
Wallet has been confirmed by the other party
Created new address
Created new address
Unit saved
Attempt to pair us with another correspondent
Pairing was successful
Pairing was successful using pairing secret
The paired device has been removed
History update started
History update finished
A new message string type message has been received
A new message object type message has been received
Change in permission to store message history
Created a new shared address
Signing request
Signed event
Refuse to sign
Confirmed on another device
All private payments are processed
All private payments are processed in a unit
Event for custom Request
Event for custom JustSaying
Database is read and ready to work (only Cordova)
Error sending message via ws