Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
addressPayload = Buffer.from([])
addressAttributes = new Map()
}
const addressRoot = getAddressHash([
0,
[0, xpub],
addressPayload.length > 0 ? new Map([[1, cbor.encode(addressPayload)]]) : new Map(),
])
const addressType = 0 // Public key address
const addressData = [addressRoot, addressAttributes, addressType]
const addressDataEncoded = cbor.encode(addressData)
return base58.encode(
cbor.encode([new cbor.Tagged(24, addressDataEncoded), crc32(addressDataEncoded)])
)
}
function tagCID (cid) {
if (typeof cid === 'string') {
cid = new CID(cid).buffer
} else if (CID.isCID(cid)) {
cid = cid.buffer
}
return new cbor.Tagged(CID_CBOR_TAG, Buffer.concat([
Buffer.from('00', 'hex'), // thanks jdag
cid
]))
}
const tagged = transform(elem, val => {
if (!isObject(val)) {
return val
}
if (seen.some(obj => orderStringify(obj) === orderStringify(val))) {
return tasks.error('the object passed has circular references')
}
seen.push(val)
if (!(cid = val['/'])) {
return val
}
if (isString(cid)) {
cid = new CID(cid.split('/')[0]).buffer
}
return new cbor.Tagged(CID_CBOR_TAG, Buffer.concat([
Buffer.from('00', 'hex'), cid
]))
})
try {
const tagged = transform(obj, val => {
if (val.constructor !== Object) {
return val
}
if (seen.some(obj => orderStringify(obj) === orderStringify(val))) {
stop = true
return cb(new Error('the object passed has circular references'))
}
seen.push(val)
if (!(cid = val['/'])) {
return val
}
if (typeof cid === 'string') {
cid = new CID(cid.split('/')[0]).buffer
}
return new cbor.Tagged(CID_CBOR_TAG, Buffer.concat([
Buffer.from('00', 'hex'), cid
]))
})
if (!stop) {
function encodeCBOR(encoder) {
return encoder.pushAny([
type,
new Tagged(24, encode([Buffer.from(txHash, 'hex'), outputIndex]), null),
])
}
function encodeCBOR(encoder) {
return encoder.pushAny([type, new Tagged(24, encode([extendedPublicKey, signature]), null)])
}
function encodeCBOR(encoder) {
return encoder.pushAny([
type,
new Tagged(24, encode([Buffer.from(txHash, 'hex'), outputIndex]), null),
])
}