Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (fee) => {
if (typeof fee === 'string' && fee.indexOf('-') !== -1) {
const feeRange = fee.split('-').map(f => new Bignum(f))
if (feeRange[1] < feeRange[0]) {
return feeRange[0]
}
return new Bignum(randomFee(feeRange[0], feeRange[1]))
}
return new Bignum(fee)
}
module.exports = (fee) => {
if (typeof fee === 'string' && fee.indexOf('-') !== -1) {
const feeRange = fee.split('-').map(f => new Bignum(f))
if (feeRange[1] < feeRange[0]) {
return feeRange[0]
}
return new Bignum(randomFee(feeRange[0], feeRange[1]))
}
return new Bignum(fee)
}
wallets,
null,
true,
)
for (const transaction of transactions) {
totalDeductions = totalDeductions
.plus(transactionAmount)
.plus(transaction.fee)
}
if (this.options.copy) {
this.copyToClipboard(transactions)
return
}
const expectedSenderBalance = new Bignum(walletBalance).minus(
totalDeductions,
)
if (!this.options.skipValidation) {
logger.info(
`Sender expected ending balance: ${Command.__arktoshiToArk(
expectedSenderBalance,
)}`,
)
}
const runOptions = {
primaryAddress,
transactions,
wallets,
transactionAmount,
expectedSenderBalance,
public __getBlockId(block) {
const hash = this.__getHash(block);
const blockBuffer = Buffer.alloc(8);
for (let i = 0; i < 8; i++) {
blockBuffer[i] = hash[7 - i];
}
return new Bignum(blockBuffer.toString("hex"), 16).toString();
}
Object.keys(wallet).forEach(key => {
if (['balance'].indexOf(key) !== -1) {
return
}
coldWallet[key] =
key !== 'voteBalance' ? wallet[key] : new Bignum(wallet[key])
})
}
exports.calculateApproval = (delegate, height) => {
const constants = config.getConstants(height)
const totalSupply = new Bignum(config.genesisBlock.totalAmount).plus((height - constants.height) * constants.reward)
return delegate.balance.times(100).dividedBy(totalSupply).toNumber().toFixed(2)
}
Object.keys(wallet).forEach(key => {
if (["balance"].indexOf(key) !== -1) {
return;
}
coldWallet[key] = key !== "voteBalance" ? wallet[key] : new Bignum(wallet[key]);
});
}
exports.calculateApproval = (delegate, height) => {
const config = app.resolvePlugin('config')
if (!height) {
height = app.resolvePlugin('blockchain').getLastBlock().data.height
}
const constants = config.getConstants(height)
const totalSupply = new Bignum(config.genesisBlock.totalAmount).plus(
(height - constants.height) * constants.reward,
)
const voteBalance = new Bignum(delegate.voteBalance)
return +voteBalance
.times(100)
.dividedBy(totalSupply)
.toFixed(2)
}
public __getBytes(block) {
const size = 4 + 4 + 4 + 8 + 4 + 4 + 8 + 8 + 4 + 4 + 4 + 32 + 32 + 64;
try {
const byteBuffer = new ByteBuffer(size, true);
byteBuffer.writeInt(block.version);
byteBuffer.writeInt(block.timestamp);
byteBuffer.writeInt(block.height);
if (block.previousBlock) {
const previousBlock = Buffer.from(new Bignum(block.previousBlock).toString(16), "hex");
for (let i = 0; i < 8; i++) {
byteBuffer.writeByte(previousBlock[i]);
}
} else {
for (let i = 0; i < 8; i++) {
byteBuffer.writeByte(0);
}
}
byteBuffer.writeInt(block.numberOfTransactions);
byteBuffer.writeLong(block.totalAmount);
byteBuffer.writeLong(block.totalFee);
byteBuffer.writeLong(block.reward);
byteBuffer.writeInt(block.payloadLength);
module.exports = value => new Bignum(value)