How to use ripple-binary-codec - 10 common examples

To help you get started, we’ve selected a few ripple-binary-codec examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ripple / ripple-lib / src / transaction / sign.ts View on Github external
function checkTxSerialization(serialized: string, tx: TransactionJSON): void {
  // Decode the serialized transaction:
  const decoded = binaryCodec.decode(serialized)

  // ...And ensure it is equal to the original tx, except:
  // - It must have a TxnSignature or Signers (multisign).
  if (!decoded.TxnSignature && !decoded.Signers) {
    throw new utils.common.errors.ValidationError(
      'Serialized transaction must have a TxnSignature or Signers property'
    )
  }
  // - We know that the original tx did not have TxnSignature, so we should delete it:
  delete decoded.TxnSignature
  // - We know that the original tx did not have Signers, so if it exists, we should delete it:
  delete decoded.Signers

  // - If SigningPubKey was not in the original tx, then we should delete it.
  //   But if it was in the original tx, then we should ensure that it has not been changed.
  if (!tx.SigningPubKey) {
github BitGo / BitGoJS / test / v2 / unit / coins / xrp.js View on Github external
}];

      for (const currentFees of fees) {
        nock('https://test.bitgo.com/api/v2/txrp/public')
        .get('/feeinfo')
        .reply(200, {
          date: '2017-10-18T18:28:13.083Z',
          height: 3353255,
          xrpBaseReserve: '20000000',
          xrpIncReserve: '5000000',
          xrpOpenLedgerFee: currentFees.open,
          xrpMedianFee: currentFees.median
        });
        const details = yield nockBasecoin.supplementGenerateWallet({}, keychains);
        const disableMasterKey = rippleBinaryCodec.decode(details.initializationTxs.disableMasterKey);
        const forceDestinationTag = rippleBinaryCodec.decode(details.initializationTxs.forceDestinationTag);
        const setMultisig = rippleBinaryCodec.decode(details.initializationTxs.setMultisig);
        disableMasterKey.Fee.should.equal(currentFees.expected);
        forceDestinationTag.Fee.should.equal(currentFees.expected);
        setMultisig.Fee.should.equal(currentFees.expected);
      }
    }));
github BitGo / BitGoJS / test / v2 / unit / coins / xrp.js View on Github external
expected: '10500'
      }];

      for (const currentFees of fees) {
        nock('https://test.bitgo.com/api/v2/txrp/public')
        .get('/feeinfo')
        .reply(200, {
          date: '2017-10-18T18:28:13.083Z',
          height: 3353255,
          xrpBaseReserve: '20000000',
          xrpIncReserve: '5000000',
          xrpOpenLedgerFee: currentFees.open,
          xrpMedianFee: currentFees.median
        });
        const details = yield nockBasecoin.supplementGenerateWallet({}, keychains);
        const disableMasterKey = rippleBinaryCodec.decode(details.initializationTxs.disableMasterKey);
        const forceDestinationTag = rippleBinaryCodec.decode(details.initializationTxs.forceDestinationTag);
        const setMultisig = rippleBinaryCodec.decode(details.initializationTxs.setMultisig);
        disableMasterKey.Fee.should.equal(currentFees.expected);
        forceDestinationTag.Fee.should.equal(currentFees.expected);
        setMultisig.Fee.should.equal(currentFees.expected);
      }
    }));
  });
github ripple / ripple-lib / test / fixtures / orderbook.js View on Github external
module.exports.transactionWithCreatedOffer = function(options) {
  options = options || {};
  _.defaults(options, {
    account: addresses.ACCOUNT,
    amount: '1.9951'
  });

  const takerGets = new IOUValue(options.amount);
  const takerPays = new IOUValue(module.exports.TAKER_PAYS);
  const quality = takerPays.divide(takerGets);

  const BookDirectory = binary.encodeQuality(quality.toString());

  const meta = new Meta({
    AffectedNodes: [
      {
        CreatedNode: {
          LedgerEntryType: 'Offer',
          LedgerIndex: 'AF3C702057C9C47DB9E809FD8C76CD22521012C5CC7AE95D914EC9E226F1D7E5',
          NewFields: {
            Account: options.account,
            BookDirectory: BookDirectory,
            Flags: 131072,
            Sequence: 1404,
            TakerGets: {
              currency: 'USD',
              issuer: addresses.ISSUER,
              value: options.amount
github ripple / rippled-historical-database / lib / validations / reports.js View on Github external
function parseManifest (data) {
  let man_data = new Buffer(data, 'base64');
  let manhex = man_data.toString('hex').toUpperCase();
  return binary.decode(manhex)
}
github ripple / rippled-historical-database / import / postgres / client.js View on Github external
if (options.tx_return === "hex") {
        var transaction_list = [];
        for (var i=0; i
github ripple / rippled-historical-database / lib / hbase / hbase-client.js View on Github external
var tx = { };

          try {
            tx.hash = row.rowkey;
            tx.date = smoment(row.executed_time).format();
            tx.ledger_index = Number(row.ledger_index);
            if (opts.include_ledger_hash) {
              tx.ledger_hash = row.ledger_hash;
            }

            if (opts.binary) {
              tx.tx = row.raw;
              tx.meta = row.meta;

            } else {
              tx.tx = binary.decode(row.raw);
              tx.meta = binary.decode(row.meta);
            }

            results.rows.push(tx);

          } catch (e) {
            cb(e);
            return;
          }
        });
      }
github ripple / rippled-historical-database / import / import-6409247.js View on Github external
ledger.transactions.forEach(function(tx, i) {
  var transaction      = binary.decode(tx.tx.toUpperCase());
  transaction.metaData = binary.decode(tx.meta.toUpperCase());
  transaction.hash = tx.hash;
  ledger.transactions[i] = transaction;
});
github ripple / ripple-lib / src / core / remote.js View on Github external
Remote.parseBinaryAccountTransaction = function(transaction) {
  const tx_json = binary.decode(transaction.tx_blob);
  const meta = binary.decode(transaction.meta);

  const tx_result = {
    validated: transaction.validated
  };

  tx_result.meta = meta;
  tx_result.tx = tx_json;
  tx_result.tx.hash = Transaction.from_json(tx_json).hash();
  tx_result.tx.ledger_index = transaction.ledger_index;
  tx_result.tx.inLedger = transaction.ledger_index;

  if (typeof meta.DeliveredAmount === 'object') {
    tx_result.meta.delivered_amount = meta.DeliveredAmount;
  } else {
    switch (typeof tx_json.Amount) {