How to use the ripple-binary-codec.encode 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
SigningPubKey: keypair.publicKey,
      TxnSignature: computeSignature(
        txToSignAndEncode,
        keypair.privateKey,
        options.signAs
      )
    }
    txToSignAndEncode.Signers = [{Signer: signer}]
  } else {
    txToSignAndEncode.TxnSignature = computeSignature(
      txToSignAndEncode,
      keypair.privateKey
    )
  }

  const serialized = binaryCodec.encode(txToSignAndEncode)

  checkTxSerialization(serialized, tx)

  return {
    signedTransaction: serialized,
    id: computeBinaryTransactionHash(serialized)
  }
}
github ripple / ripple-lib / src / common / hashes / index.ts View on Github external
export const computeTransactionHash = (txJSON: any): string => {
  return computeBinaryTransactionHash(encode(txJSON))
}
github BitGo / BitGoJS / modules / core / src / v2 / coins / xrp.ts View on Github external
return co(function *() {
      if (!params.txHex) {
        throw new Error('missing required param txHex');
      }
      let transaction;
      let txHex;
      try {
        transaction = rippleBinaryCodec.decode(params.txHex);
        txHex = params.txHex;
      } catch (e) {
        try {
          transaction = JSON.parse(params.txHex);
          txHex = rippleBinaryCodec.encode(transaction);
        } catch (e) {
          throw new Error('txHex needs to be either hex or JSON string for XRP');
        }
      }
      const id = computeBinaryTransactionHash(txHex);
      const address = transaction.Destination + ((transaction.DestinationTag >= 0) ? '?dt=' + transaction.DestinationTag : '');
      return {
        displayOrder: ['id', 'outputAmount', 'changeAmount', 'outputs', 'changeOutputs', 'fee'],
        id: id,
        changeOutputs: [],
        outputAmount: transaction.Amount,
        changeAmount: 0,
        outputs: [
          {
            address,
            amount: transaction.Amount
github ripple / rippled-historical-database / lib / validations / reports.js View on Github external
function verifyManifest(manifest) {
  const signature = manifest.MasterSignature;
  delete manifest.Signature;
  delete manifest.MasterSignature;

  const manifest_data = new Buffer('MAN\0').toJSON().data.concat(toBytes(binary.encode(manifest)));

  let master_public_bytes = toBytes(manifest.PublicKey);
  master_public_bytes.shift();

  return Ed25519.verify(manifest_data, toBytes(signature), master_public_bytes);
}
github ripple / ripple-lib / src / core / transaction.js View on Github external
Transaction.prototype.serialize = function() {
  return binary.encode(this.tx_json);
};
github ripple / rippled-historical-database / lib / utils.js View on Github external
module.exports.toHex = function (input) {
  return binary.encode(input);
}