Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
bb.writeInt(transaction.timestamp);
bb.append(transaction.senderPublicKey, "hex");
bb.writeLong(transaction.fee);
if(transaction.vendorFieldHex){
bb.writeByte(transaction.vendorFieldHex.length/2);
bb.append(transaction.vendorFieldHex, "hex");
}
else {
bb.writeByte(0x00);
}
switch (transaction.type) {
case 0: // Transfer
bb.writeLong(transaction.amount);
bb.writeInt(transaction.expiration);
bb.append(bs58check.decode(transaction.recipientId));
break;
case 1: // Signature
bb.append(transaction.asset.signature.publicKey,"hex");
break;
case 2: // Delegate
var delegateBytes = new Buffer(transaction.asset.delegate.username, "utf8");
bb.writeByte(delegateBytes.length/2);
bb.append(delegateBytes,"hex");
break;
case 3: // Vote
var voteBytes = transaction.asset.votes.map(function(vote){
return (vote[0] == "+" ? "01" : "00") + vote.slice(1);
}).join("");
function fromBase58Check(address) {
const payload = bs58check.decode(address);
// TODO: 4.0.0, move to "toOutputScript"
if (payload.length < 21)
throw new TypeError(address + ' is too short');
if (payload.length > 21)
throw new TypeError(address + ' is too long');
const version = payload.readUInt8(0);
const hash = payload.slice(1);
return { version, hash };
}
exports.fromBase58Check = fromBase58Check;
function fromBase58Check(address) {
const payload = bs58check.decode(address);
// TODO: 4.0.0, move to "toOutputScript"
if (payload.length < 21) throw new TypeError(address + ' is too short');
if (payload.length > 21) throw new TypeError(address + ' is too long');
const version = payload.readUInt8(0);
const hash = payload.slice(1);
return { version, hash };
}
exports.fromBase58Check = fromBase58Check;
if (transaction.vendorField) {
const vf = Buffer.from(transaction.vendorField, 'utf8')
bb.writeByte(vf.length)
bb.append(vf)
} else if (transaction.vendorFieldHex) {
bb.writeByte(transaction.vendorFieldHex.length / 2)
bb.append(transaction.vendorFieldHex, 'hex')
} else {
bb.writeByte(0x00)
}
if (transaction.type === TRANSACTION_TYPES.TRANSFER) {
bb.writeUInt64(+new Bignum(transaction.amount).toFixed())
bb.writeUInt32(transaction.expiration || 0)
bb.append(bs58check.decode(transaction.recipientId))
} else if (transaction.type === TRANSACTION_TYPES.VOTE) {
const voteBytes = transaction.asset.votes
.map(vote => (vote[0] === '+' ? '01' : '00') + vote.slice(1))
.join('')
bb.writeByte(transaction.asset.votes.length)
bb.append(voteBytes, 'hex')
} else if (transaction.type === TRANSACTION_TYPES.SECOND_SIGNATURE) {
bb.append(transaction.asset.signature.publicKey, 'hex')
} else if (transaction.type === TRANSACTION_TYPES.DELEGATE_REGISTRATION) {
const delegateBytes = Buffer.from(
transaction.asset.delegate.username,
'utf8',
)
bb.writeByte(delegateBytes.length)
bb.append(delegateBytes, 'hex')
} else if (transaction.type === TRANSACTION_TYPES.MULTI_SIGNATURE) {
static validate(address, networkVersion) {
if (!networkVersion) {
networkVersion = configManager.get('pubKeyHash')
}
try {
const decode = bs58check.decode(address)
return decode[0] === networkVersion
} catch (e) {
return false
}
}
}
validateAddress(address, networkVersion) {
if (!networkVersion) {
networkVersion = configManager.get('pubKeyHash')
}
try {
const decode = bs58check.decode(address)
return decode[0] === networkVersion
} catch (e) {
return false
}
}
validateAddress (address, version) {
if (!version) {
version = configManager.get('pubKeyHash')
}
try {
const decode = bs58check.decode(address)
return decode[0] === version
} catch (e) {
return false
}
}
}
function validateAddress(address, version){
if(!version){
version = networkVersion;
}
try {
var decode = bs58check.decode(address);
return decode[0] == version;
} catch(e){
return false;
}
}
function validateAddress(address, version){
if(!version){
version = networkVersion;
}
try {
var decode = bs58check.decode(address);
return decode[0] == version;
} catch(e){
return false;
}
}
const _address = lazy.value(() => {
const payload = bs58check.decode(a.address);
const version = payload.readUInt8(0);
const hash = payload.slice(1);
return { version, hash };
});
const _chunks = lazy.value(() => {