How to use the bytebuffer.fromHex function in bytebuffer

To help you get started, we’ve selected a few bytebuffer 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 lino-network / lino-js / src / transport / encoder.ts View on Github external
export function convertToInternalPubKey(rawPubKey: string, type: string): InternalPubKey {
  const res: InternalPubKey = {
    type: type,
    value: ByteBuffer.fromHex(rawPubKey).toString('base64')
  };
  return res;
}
// convert raw sig to internal sig format
github chainside / btcnodejs / lib / crypto.js View on Github external
static fromHex(hex) {
        const buffer = new ByteBuffer.fromHex(hex);
        return new Privatekey(buffer);
    }
github BTWhite / BTWChain / src / core / transactions.js View on Github external
this.getBytes = function (trs) {
        return ByteBuffer.fromHex(trs.asset.storage.content).toBuffer();
    };
github bitshares / bitshares-ui / plasma / libraries / @graphene / serializer / src / serializer.js View on Github external
fromHex(hex) {
        var b = ByteBuffer.fromHex(hex, ByteBuffer.LITTLE_ENDIAN);
        return this.fromByteBuffer(b);
    }
github chainside / btcnodejs / lib / transaction.js View on Github external
_.forEach(this.outputs, output => {
            let ser_buf = output.serialize();
            let ser_out = $.hexToBytes(ser_buf.toHex(0, ser_buf.capacity()));

            data.push(ser_out);
        });
        const hex = $.bytesToHex(_.flatten(data));
        const hash = shajs("sha256")
            .update(
                shajs("sha256")
                    .update(hex, "hex")
                    .digest("hex"),
                "hex"
            )
            .digest("hex");
        const buffer = new ByteBuffer.fromHex(hash);
        return buffer;
    }
}
github chainside / btcnodejs / lib / address.js View on Github external
static fromBase58(base58addr) {
        const address_data = addr.fromBase58Check(base58addr);
        const hash = new ByteBuffer.fromHex(address_data.hash.toString("hex"));
        const type = Address.versions[address_data.version]["type"];
        const network = Address.versions[address_data.version]["network"];
        return new Address(type, hash, network);
    }
github lino-network / lino-js / src / transport / encoder.ts View on Github external
var buffer = ByteBuffer.fromHex(msg.new_reset_public_key);
    encodedMsg.new_reset_public_key = getByteArray(buffer);
  }

  if ('new_transaction_public_key' in msg) {
    var buffer = ByteBuffer.fromHex(msg.new_transaction_public_key);
    encodedMsg.new_transaction_public_key = getByteArray(buffer);
  }

  if ('new_app_public_key' in msg) {
    var buffer = ByteBuffer.fromHex(msg.new_app_public_key);
    encodedMsg.new_app_public_key = getByteArray(buffer);
  }

  if ('validator_public_key' in msg) {
    var buffer = ByteBuffer.fromHex(msg.validator_public_key);
    encodedMsg.validator_public_key = getByteArray(buffer);
  }

  return encodedMsg;
}
github lino-network / lino-js / src / transport / encoder.ts View on Github external
export function encodeTx(
  msgs: StdMsg[],
  rawPubKey: string[],
  rawSigDER: string[],
  maxFeeInCoin: number
): string {
  var sigs: StdSignature[] = [];
  for (var _i = 0; _i < rawPubKey.length; _i++) {
    const stdSig: StdSignature = {
      pub_key: convertToInternalPubKey(rawPubKey[_i], _TYPE.PubKeySecp256k1),
      signature: ByteBuffer.fromHex(rawSigDER[_i]).toString('base64')
    };
    sigs.push(stdSig);
  }

  const stdTx: StdTx = {
    msg: msgs,
    signatures: sigs,
    fee: getFee(maxFeeInCoin)
  };

  const authStdTx: StdMsg = {
    type: 'auth/StdTx',
    value: number2StringInObject(stdTx)
  };
  const jsonStr = JSON.stringify(authStdTx);
  return ByteBuffer.btoa(jsonStr);
github chainside / btcnodejs / lib / scripts.js View on Github external
p2shHash() {
        const sha256 = shajs("sha256")
            .update(this.body.toHex(0, this.body.capacity()), "hex")
            .digest("hex");
        const ripe = new ripemd160().update(sha256, "hex").digest("hex");
        return new ByteBuffer.fromHex(ripe);
    }
github chainside / btcnodejs / lib / transaction.js View on Github external
_.forEach(this.inputs, input => {
            let txid = $.hexToBytes(input.txid).reverse();
            let vout = $.numToBytes(input.out, 4);
            data.push(txid);
            data.push(vout);
        });
        const hex = $.bytesToHex(_.flatten(data));
        const hash = shajs("sha256")
            .update(
                shajs("sha256")
                    .update(hex, "hex")
                    .digest("hex"),
                "hex"
            )
            .digest("hex");
        const buffer = new ByteBuffer.fromHex(hash);
        return buffer;
    }