LN Wallet Api

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

getBalance

window.bitpocket.ln.getBalance()

Get Lightning wallet funding balance

Parameters

none

Returns

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

Example

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

> {"total":10546}

getTokenList

window.bitpocket.ln.getTokenList()

Get Token List

Parameters

none

Returns

  • Promise - Object:
    • total - number : the total satoshis
    • list - Object[] :
      • assetId - string : the id of token asset.
      • assetNum - number : the number of the asset(Please mind the decimalDisplay of the token asset. e.g. If the user owned 1 BOOM asset, and the decimalDisplay of the BOOM assset is 8, then the assetNum should be 100000000(1*Math.pow(10,8))).
      • assetUsd - number : the usd value of the asset.
      • decimalDisplay - number : the decimals of token.What is Decimal Display?
      • description - string : the description of token.
      • image - string : the image of token.
      • totalSupply - string : the total supply of token.
      • unitPrice - number : the unit price of token in sats.

Example

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

> {
    "total":2,
    "list":[
      {
                "assetId": "3bcd39390b328dca41a0120a11ff139cd9422a252b06deec09273a806d66c8d9",
                "ticker": "BitBOOM",
                "image": "https://bitboom.fun/picture/2024/09/30/c3d2e158b8664046ad3493f7f1991545.webp",
                "assetNum": 216900000000,
                "assetUsd": 0.01246996491300000000,
                "unitPrice": 0.000005749177,
                "decimalDisplay": 8,
                "totalSupply": "210000000000000000",
                "description": "Let's make BTC BOOOOOOOOOOOOOOOOOOOOM!",
            },
            {
                "assetId": "5626ba9005d24c39a2423aa8a2c588340781f7dd46d53b4fe7f9244b4774da0e",
                "ticker": "BOOMDOGE",
                "image": "https://bitboom.fun/picture/2025/03/13/ed9ee2a28bbf459c84835718c96db44b.webp",
                "assetNum": 1,
                "assetUsd": 0.00000000000000000000,
                "unitPrice": 0.000005562015,
                "decimalDisplay": 0,
                "totalSupply": "210000000000000000",
                "description": "Boom Doge We are the first",
            }
    ]
}

getNFTList

window.bitpocket.ln.getNFTList()

Get NFT List

Parameters

none

Returns

  • Promise - Object:
    • total - number : the total satoshis
    • list - Object[] :
      • assetId - string : the id of the nft .
      • ticker - string : the name of the nft .
      • image - string : the image of the token.
      • assetNum - number : the number of the nft.
      • assetUsd - number : the usd value of the nft.
      • decimalDisplay - number : the decimals of token. What is Decimal Display?
      • description - string : the description of token.
      • totalSupply - string : the total supply of token.
      • unitPrice - number : the unit price of token in sats.

Example

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

> {
    "total":2,
    "list":[
       {
                "assetId": "478325681ea2aad134de13bbbaf343d465bad6f3dce57aa1adfa0641dde3ffc8",
                "ticker": "hello.btc",
                "image": "https://btc.superdid.io/picture/2025/10/10/hellobtc.png",
                "assetNum": 1,
                "assetUsd": 0,
                "unitPrice": 0,
                "decimalDisplay": 0,
                "totalSupply": "1",
                "assetType": 1,
                "description": "hello.btc, a web3 domain name for btc name service.",
            },
            {
                "assetId": "6aaafab68d8bd67863f9a399f6fce1874a1dbf24ffc21886beced5cda2162d7e",
                "ticker": "exchange.btc",
                "image": "https://btc.superdid.io/picture/2025/10/10/exchangebtc.png",
                "assetNum": 1,
                "assetUsd": 0,
                "unitPrice": 0,
                "decimalDisplay": 0,
                "totalSupply": "1",
                "assetType": 1,
                "description": "exchange.btc, a web3 domain name for btc name service."
            },
    ]
}

getAssetMetaInfo

window.bitpocket.ln.getAssetMetaInfo(assetId)

Get asset meta information of token

Parameters

  • assetId - string: the asset Id of the token

Returns

  • Promise - Object:
    • assetId - string : the id of token asset.
    • ticker - string : the name of token asset.
    • image - string : the image of token asset.
    • decimalDisplay - number : the decimals of token. What is Decimal Display?
    • description - string : the description of token.
    • totalSupply - string : the total supply of token.
    • unitPrice - number : the unit price of token in sats.
try {
    let res = await window.bitpocket.ln.getAssetMetaInfo(assetId);
    console.log(res)
} catch (e) {
    console.log(e);
}

getNftMetaInfo

window.bitpocket.ln.getNftMetaInfo(assetId)

Get NFT meta information.

Parameters

  • assetId - string: the asset Id of the NFT

Returns

  • Promise - Object:
    • assetId - string : the id of token asset.
    • ticker - string : the name of token asset.
    • image - string : the image of token asset.
    • description - string : the description of token.
try {
    let res = await window.bitpocket.ln.getNftMetaInfo(assetId);
    console.log(res)
} catch (e) {
    console.log(e);
}

sendSats

window.bitpocket.ln.sendSats(appKey,toAddress, satoshis,outTradeNo)

Send Sats

Parameters

  • apiKey - string: the app key of the dapp.
  • toAddress - string: the ln address to send, we currently only support @bitbooom.fun lightning address
  • satoshis - number: the satoshis to send
  • outTradeNo - string: the out trade number of the transaction,should be unique in the DApp, used to identify the transaction.(max lenth: 32)

Returns

  • Promise - string: txid

Example

try {
  const apiKey ='aedfbfghklllllljjj'
  const toAddress='bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr@bitbooom.fun'
  const satoshis = 1000

// Out trade number is generated by DApp, which is used to identify the transaction, and should be unique in the DApp.
// when the transaction is submitted, the DApp can query the transaction status by this outTradeNo or the returned txId.
  const outTradeNo = '01234567890123456789012345678901'  

  let txId = await window.bitpocket.ln.sendSats(apiKey,
    toAddress,
    satoshis,
    outTradeNo
  );
  console.log(txId);
} catch (e) {
  console.log(e);
}

sendToken

window.bitpocket.ln.sendToken(appKey,assetId, toAddress, amount, outTradeNo)

Parameters

  • apiKey - string: the api key of the dapp.
  • assetId - string: the id of token asset.
  • toAddress - string: the address to send token.
  • amount - number: the amount of token to send(Please mind the decimalDisplay of the token asset, e.g. if you transfer 1 BOOM asset, and the decimalDisplay of the BOOM asset is 8, then the amount should be 100000000(1*Math.pow(10,8))). What is Decimal Display?
  • outTradeNo - string: the out trade no of the transaction, used to identify the transaction.(max lenth: 32)

Returns

  • Promise - Object
    • txid - string : the txid of the transaction.

Example

try {
    const apiKey ='aedfbfghklllllljjj'
    const assetId='3bcd39390b328dca41a0120a11ff139cd9422a252b06deec09273a806d66c8d9'
    const toAddress='bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr@bitbooom.fun'

// Out trade number is generated by DApp, which is used to identify the transaction, and should be unique in the DApp.
// when the transaction is submitted, the DApp can query the transaction status by this outTradeNo or the returned txId.
    const outTradeNo = '01234567890123456789012345678901'  

    const amount = 1*Math.pow(10,8) // As the decimal display of BOOM is 8, so 1*Math.pow(10,8) stands for 1 BOOM 
    let res = await window.bitpocket.ln.sendToken(apiKey,assetId, toAddress, amount, outTradeNo);
    console.log(res)
} catch (e) {
    console.log(e);
}

sendNFT

window.bitpocket.ln.sendNFT(appKey,assetId, toAddress, outTradeNo)

Parameters

  • apiKey - string: the api key of the dapp.
  • assetId - string: the id of token asset.
  • toAddress - string: the address to send token.
  • outTradeNo - string: the out trade no of the transaction, used to identify the transaction.(max lenth: 32)

Returns

  • Promise - Object
    • txid - string : the txid of the transaction.

Example

try {
    const apiKey ='aedfbfghklllllljjj'
    const assetId='478325681ea2aad134de13bbbaf343d465bad6f3dce57aa1adfa0641dde3ffc8'
    const toAddress='bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr@bitbooom.fun'

// Out trade number is generated by DApp, which is used to identify the transaction, and should be unique in the DApp.
// when the transaction is submitted, the DApp can query the transaction status by this outTradeNo or the returned txId.
    const outTradeNo = '01234567890123456789012345678901'  

    let res = await window.bitpocket.ln.sendNFT(apiKey,assetId, toAddress, outTradeNo);
    console.log(res)
} catch (e) {
    console.log(e);
}

results matching ""

    No results matching ""