Caravan Documentation
    Preparing search index...

    Decoder class for BC UR data.

    Decodes a hex string from a collection of UR parts.

    Designed for use by a calling application which is typically in a loop parsing an animated sequence of QR codes.

    import {BCURDecoder} from "@caravan/wallets";
    const decoder = new BCURDecoder();

    // Read data until the decoder is complete...
    while (!decoder.isComplete()) {

    // Progress can be fed back to the calling application for visualization in its UI
    console.log(decoder.progress()); // {totalParts: 10, partsReceived; 3}

    // Application-defined function to obtain a single UR part string.
    const part = scanQRCode();
    decoder.receivePart(part);
    }

    // Check for an error
    if (decoder.isSuccess()) {

    // Data can be passed back to the calling application
    console.log(decoder.data()); // "deadbeef"

    } else {

    // Errors can be passed back to the calling application
    console.log(decoder.errorMessage());
    }
    Index

    Constructors

    Properties

    error: any
    summary: any

    Methods

    • Returns the current progress of this decoder.

      Returns { partsReceived: any; totalParts: any }

      import {BCURDecoder} from "@caravan/wallets";
      const decoder = BCURDecoder();
      console.log(decoder.progress())
      // { totalParts: 0, partsReceived: 0 }

      decoder.receivePart(part);
      ...
      decoder.receivePart(part);
      ...
      decoder.receivePart(part);
      ...
      console.log(decoder.progress())
      // { totalParts: 10, partsReceived: 3 }
    • Receive a new UR part.

      It's OK to call this method multiple times for the same UR part.

      Parameters

      • part: string

      Returns void