How to use the ripple-binary-codec.decode function in ripple-binary-codec

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 / 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) {