Bitcoin Assets

The following provides several methods to list the wallet's assets and construct corresponding send transactions.

getBalance

window.bitpocket.unisat.getBalance()

Get BTC balance

Parameters

none

Returns

  • Promise - Object:
    • available - number : the available satoshis
    • unavailable - number : the unavailable satoshis
    • total - number : the total satoshis

Example

try {
    let res = await window.bitpocket.unisat.getBalance();
    console.log(res)
} catch (e) {
    console.log(e);
}

> {"available":10000,"unavailable":546,"total":10546}

send BTC

window.bitpocket.unisat.openBtcPayForSignedPsbt(toAddress, amountInSats)

Send BTC

Parameters

  • toAddress - string: the address to send
  • amountInSats - number: the satoshis to send

Returns

  • Promise - string: signed psbt

Example

try {
  let signedPsbt = await window.bitpocket.unisat.openBtcPayForSignedPsbt(
    "tb1qrn7tvhdf6wnh790384ahj56u0xaa0kqgautnnz",
    1000
  );
  console.log('signed psbt is ', signedPsbt);
  //... you can call window.bitpocket.unisat.pushPsbt(signedPsbt, label) to publish this tx, or you can publish it by yourself
} catch (e) {
  console.log(e);
}

results matching ""

    No results matching ""