Guides
Dash CoreDash PlatformDash.orgDash User DocsLog In
Guides

subscribeToTransactionsWithProofs

🚧

New site!

All content has been migrated to docs.dash.org. You will be automatically redirected momentarily.

Usage: await client.core.subscribeToTransactionsWithProofs(bloomFilter, options = { count: 0 })
Description: For any provided bloomfilter, it will return a ClientReadableStream streaming the transaction matching the filter.

Parameters:

parameterstyperequiredDescription
bloomFilter.vDataUint8Array/ArrayyesThe filter itself is simply a bit field of arbitrary byte-aligned size. The maximum size is 36,000 bytes.
bloomFilter.nHashFuncsNumberyesThe number of hash functions to use in this filter. The maximum value allowed in this field is 50.
bloomFilter.nTweakNumberyesA random value to add to the seed value in the hash function used by the bloom filter.
bloomFilter.nFlagsNumberyesA set of flags that control how matched items are added to the filter.
options.fromBlockHashStringyesSpecifies block hash to start syncing from
options.fromBlockHeightNumberyesSpecifies block height to start syncing from
options.countNumberno (default: 0)Number of blocks to sync, if set to 0 syncing is continuously sends new data as well

Returns : Promise|!grpc.web.ClientReadableStream<!TransactionsWithProofsResponse>

Example :

const filter; // A BloomFilter object
const stream = await client.subscribeToTransactionsWithProofs(filter, { fromBlockHeight: 0 });

stream
      .on('data', (response) => {
        const merkleBlock = response.getRawMerkleBlock();
        const transactions = response.getRawTransactions();

        if (merkleBlock) {
          const merkleBlockHex = Buffer.from(merkleBlock).toString('hex');
        }

        if (transactions) {
          transactions.getTransactionsList()
              .forEach((tx) => {
                  // tx are probabilistic, so you will have to verify it's yours
                  const tx = new Transaction(Buffer.from(tx));
              });
        }
      })
    .on('error', (err) => {
        // do something with err
      });