How to use the lisk-sdk.cryptography.bigNumberToBuffer function in lisk-sdk

To help you get started, we’ve selected a few lisk-sdk 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 LiskHQ / lisk-core / src / transactions / 7_out_transfer_transaction.ts View on Github external
protected getBasicBytes(): Buffer {
		const transactionType = cryptography.intToBuffer(this.type, constants.BYTESIZES.TYPE);
		const transactionTimestamp = cryptography.intToBuffer(
			this.timestamp,
			constants.BYTESIZES.TIMESTAMP,
			'little',
		);

		const transactionSenderPublicKey = cryptography.hexToBuffer(this.senderPublicKey);

		const transactionRecipientID = cryptography.intToBuffer(
			this.asset.recipientId.slice(0, -1),
			constants.BYTESIZES.RECIPIENT_ID,
		).slice(0, constants.BYTESIZES.RECIPIENT_ID);

		const transactionAmount = cryptography.bigNumberToBuffer(
			this.asset.amount.toString(),
			constants.BYTESIZES.AMOUNT,
			'little',
		);

		const { dappId, transactionId } = this.asset.outTransfer;
		const outAppIdBuffer = Buffer.from(dappId, 'utf8');
		const outTransactionIdBuffer = Buffer.from(transactionId, 'utf8');

		return Buffer.concat([
			transactionType,
			transactionTimestamp,
			transactionSenderPublicKey,
			transactionRecipientID,
			transactionAmount,
			Buffer.concat([outAppIdBuffer, outTransactionIdBuffer]),
github LiskHQ / lisk-core / src / transactions / 6_in_transfer_transaction.ts View on Github external
protected getBasicBytes(): Buffer {
		const transactionType = cryptography.intToBuffer(this.type, constants.BYTESIZES.TYPE);
		const transactionTimestamp = cryptography.intToBuffer(
			this.timestamp,
			constants.BYTESIZES.TIMESTAMP,
			'little',
		);

		const transactionSenderPublicKey = cryptography.hexToBuffer(this.senderPublicKey);

		const transactionRecipientID = Buffer.alloc(constants.BYTESIZES.RECIPIENT_ID);

		const transactionAmount = cryptography.bigNumberToBuffer(
			this.asset.amount.toString(),
			constants.BYTESIZES.AMOUNT,
			'little',
		);

		return Buffer.concat([
			transactionType,
			transactionTimestamp,
			transactionSenderPublicKey,
			transactionRecipientID,
			transactionAmount,
			Buffer.from(this.asset.inTransfer.dappId, 'utf8'),
		]);
	}