Namespace

headless_wallet

headless_wallet

Methods

# static isControlAddress(device_address) → {boolean}

Check that the device address is in the array of controlled addresses
Parameters:
Name Type Description
device_address

View Source start.js, line 242

boolean
Example
if (isControlAddress('0CUUZZ2UYM4ATP4HULSRH646B5V4G3JRW')) {

}

# static isReady() → {boolean}

Returns whether the wallet is ready

View Source start.js, line 61

is ready
boolean
Example
if (isReady()) {

}

# static issueChangeAddressAndSendMultiPayment(opts, onDoneopt) → {Promise.<PaymentResult>}

Issue change address and send payment with specified parameters
Parameters:
Name Type Attributes Description
opts smpOpts
onDone paymentResultCallback <optional>

View Source start.js, line 856

Promise.<PaymentResult>
Example
const opts = {};
opts.paying_addresses = 'FCNQIGCW7JIYTARK6M54NMSCPFVIY25E';
opts.amount = 10000;
opts.toAddress = '2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW';
const {unit, assocMnemonics} = await issueChangeAddressAndSendMultiPayment(opts);

# static issueChangeAddressAndSendPayment(asset, amount, to_address, device_address, onDoneopt) → {Promise.<PaymentResult>}

Issue change address and send payment
Parameters:
Name Type Attributes Description
asset string | null
amount number
to_address string
device_address string | null
onDone paymentResultCallback <optional>

View Source start.js, line 829

Promise.<PaymentResult>
Example
const address = '2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW';
const deviceAddress = '0CUUZZ2UYM4ATP4HULSRH646B5V4G3JRW';
const {unit, assocMnemonics} = await issueChangeAddressAndSendPayment(null, 10000, address, deviceAddress);

# static issueNextMainAddress(handleAddressopt) → {Promise.<string>}

Issue the next main address
Parameters:
Name Type Attributes Description
handleAddress resultCallback <optional>

View Source start.js, line 896

Promise.<string>
Example
const address = await issueNextMainAddress();

# static issueOrSelectAddressByIndex(is_change, address_index, handleAddressopt) → {Promise.<string>}

Returns the wallet's address by is_change flag and index. If the address does not exist, it will be created
Parameters:
Name Type Attributes Description
is_change number
address_index number
handleAddress resultCallback <optional>

View Source start.js, line 915

Promise.<string>
Example
const address = await issueOrSelectAddressByIndex(0, 0);

# static issueOrSelectNextMainAddress(handleAddressopt) → {Promise.<string>}

Returns the next main address, or reuses an existing address if there is already a long row of unused addresses
Parameters:
Name Type Attributes Description
handleAddress resultCallback <optional>

View Source start.js, line 879

Promise.<string>
Example
const address = await issueOrSelectNextMainAddress();

# static issueOrSelectStaticChangeAddress(handleAddressopt) → {Promise.<string>}

Returns static change address, which is the same as the first change address. If the address does not exist, it will be created
Parameters:
Name Type Attributes Description
handleAddress resultCallback <optional>

View Source start.js, line 936

Promise.<string>
Example
const address = await issueOrSelectStaticChangeAddress();

# static readFirstAddress(handleAddressopt) → {Promise.<string>}

Returns the first address of the wallet
Parameters:
Name Type Attributes Description
handleAddress resultCallback <optional>

View Source start.js, line 276

Promise.<string>
Example
const address = await readFirstAddress();

# static readSingleAddress(handleAddressopt) → {Promise.<string>}

Returns the address of the single-address wallet, throws if the wallet is not single-address
Parameters:
Name Type Attributes Description
handleAddress resultCallback <optional>

View Source start.js, line 254

Promise.<string>
Example
const address = await readSingleAddress();

# static readSingleWallet(handleWalletopt) → {Promise.<string>}

Returns the wallet ID. There should be only one wallet, throws otherwise.
Parameters:
Name Type Attributes Description
handleWallet resultCallback <optional>

View Source start.js, line 316

Promise.<string>
Example
const wallet = await readSingleWallet();

# static sendAllBytes(to_address, recipient_device_address, onDoneopt) → {Promise.<PaymentResult>}

Sends all bytes from all addresses
Parameters:
Name Type Attributes Description
to_address string
recipient_device_address string | null
onDone paymentResultCallback <optional>

View Source start.js, line 672

Promise.<PaymentResult>
Example
const peerAddress = '2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW';
const peerDeviceAddress = '0CUUZZ2UYM4ATP4HULSRH646B5V4G3JRW';
const {unit, assocMnemonics} = await sendAssetFromAddress(peerAddress, peerDeviceAddress);

# static sendAllBytesFromAddress(from_address, to_address, recipient_device_address, onDoneopt) → {Promise.<PaymentResult>}

Sends all bytes from the specified address
Parameters:
Name Type Attributes Description
from_address string
to_address string
recipient_device_address string | null
onDone paymentResultCallback <optional>

View Source start.js, line 711

Promise.<PaymentResult>
Example
const myAddress = 'FCNQIGCW7JIYTARK6M54NMSCPFVIY25E';
const peerAddress = '2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW';
const peerDeviceAddress = '0CUUZZ2UYM4ATP4HULSRH646B5V4G3JRW';
const {unit, assocMnemonics} = await sendAllBytesFromAddress(myAddress, peerAddress, peerDeviceAddress);

# static sendAssetFromAddress(asset, amount, from_address, to_address, recipient_device_address, onDoneopt) → {Promise.<PaymentResult>}

Sends a payment in the specified asset from the specified address
Parameters:
Name Type Attributes Description
asset string | null
amount number
from_address string
to_address string
recipient_device_address string | null
onDone paymentResultCallback <optional>

View Source start.js, line 752

Promise.<PaymentResult>
Example
const myAddress = 'FCNQIGCW7JIYTARK6M54NMSCPFVIY25E';
const peerAddress = '2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW';
const peerDeviceAddress = '0CUUZZ2UYM4ATP4HULSRH646B5V4G3JRW';
const {unit, assocMnemonics} = await sendAssetFromAddress(null, 10000, myAddress, peerAddress, peerDeviceAddress);

# static sendData(opts, onDoneopt) → {Promise.<string>}

Publish data to DAG
Parameters:
Name Type Attributes Description
opts Object
onDone paymentResultCallback <optional>

View Source start.js, line 792

Promise.<string>
Example
const opts = {
  app: 'text',
  payload: 'hello Obyte!'
};
const unit = await sendData(opts);

# static sendMultiPayment(opts, onDoneopt) → {Promise.<PaymentResult>}

Sends payment with specified parameters. See more examples in the documentation
Parameters:
Name Type Attributes Description
opts smpOpts
onDone paymentResultCallback <optional>

View Source start.js, line 585

Promise.<PaymentResult>
Examples
const opts = {};
opts.paying_addresses = ['FCNQIGCW7JIYTARK6M54NMSCPFVIY25E'];
opts.change_address = 'FCNQIGCW7JIYTARK6M54NMSCPFVIY25E';
opts.amount = 10000;
opts.toAddress = '2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW';
const {unit, assocMnemonics} = await sendMultiPayment(opts);
const datafeed = {key: "value"};
const objMessage = {
   app: "data_feed",
   payload_location: "inline",
   payload_hash: objectHash.getBase64Hash(datafeed),
   payload: datafeed
};
var opts = {
   paying_addresses: [my_address],
   change_address: my_address,
   messages: [objMessage]
};

const {unit, assocMnemonics} = await sendMultiPayment(opts);
const opts = {};
opts.paying_addresses = ['FCNQIGCW7JIYTARK6M54NMSCPFVIY25E'];
opts.change_address = 'FCNQIGCW7JIYTARK6M54NMSCPFVIY25E';
opts.base_outputs = [{address: "2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW", amount: 10000}];
const {unit, assocMnemonics} = await sendMultiPayment(opts);

# static sendPaymentUsingOutputs(asset, outputs, change_address, onDoneopt) → {Promise.<PaymentResult>}

Sends payment using the specified outputs
Parameters:
Name Type Attributes Description
asset
outputs
change_address
onDone paymentResultCallback <optional>

View Source start.js, line 630

Promise.<PaymentResult>
Example
const address = await issueOrSelectStaticChangeAddress();
const outputs = [
    {amount: 10000, address: 'FCNQIGCW7JIYTARK6M54NMSCPFVIY25E'},
    {amount: 0, address: address}
];
const {unit, assocMnemonics} = await sendPaymentUsingOutputs(null, outputs, address);

# static signMessage(signing_address, message, cbopt) → {Promise.<Object>}

Signs message
Parameters:
Name Type Attributes Description
signing_address
message
cb signMessageCB <optional>

View Source start.js, line 991

objUnit
Promise.<Object>
Example
const objUnit = await signMessage('2T35YT6L53OYFEUKIOXBQRKUZD4B3CYW', 'hello');

# static signWithLocalPrivateKey(wallet_id, account, is_change, address_index, text_to_sign, handleSigopt) → {Promise.<string>}

Signs a transaction/message using the local private key
Parameters:
Name Type Attributes Description
wallet_id string
account number
is_change number
address_index number
text_to_sign string
handleSig signWithLocalPrivateKeyCB <optional>

View Source start.js, line 354

Promise.<string>
Example
const walletId = '+lCx+8UGlbwdXC8ZlnQeuQZ2cKI5fyaWyxzGFXUEnbA=';
const sign = await signWithLocalPrivateKey(walletId, 0, 0, 0, 'hello');

# async static waitTillReady()

Waits for the wallet to be ready

View Source start.js, line 72

Example
await waitTillReady();

# async static waitUntilMyUnitBecameStable()

Waits for the unit to become stable. Applies only to units sent from or to our wallet. Returns immediately if the unit is already stable.

View Source start.js, line 480

Example
await waitUntilMyUnitBecameStable(unit);