Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cc-assetid-encoder

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cc-assetid-encoder - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

22

assetIdEncoder.js

@@ -5,4 +5,3 @@ var cs = require('coinstring')

var LOCKEPADDING = 0x30
var TESTNET = 0x6f
var MAINNET = 0x00
var NETWORKVERSIONS = [0x00, 0x05, 0x6f, 0xc4]

@@ -21,15 +20,8 @@ var createId = function (publicKey, padding) {

var createIdFromAddress = function (address, padding) {
var firstChar = address.slice(0, 1)
var version
switch (firstChar) {
case '1':
version = MAINNET
break
case 'm':
version = TESTNET
break
default:
throw new Error('Unrecognized address network')
}
return cs.encode(cs.decode(address, version), padding)
address = cs.decode(address)
var version = address.slice(0, 1)
// if (version[0] === 4) version = address.slice(0, 4)
address = address.slice(version.length, 21)
if (NETWORKVERSIONS.indexOf(parseInt(version.toString('hex'), 16)) === -1) throw new Error('Unrecognized address network')
return cs.encode(address, padding)
}

@@ -36,0 +28,0 @@

{
"name": "cc-assetid-encoder",
"version": "0.2.1",
"version": "0.2.2",
"description": "Creates an Asset Id for Issuance transaction",

@@ -5,0 +5,0 @@ "main": "assetIdEncoder.js",

@@ -87,3 +87,3 @@ var assetId = require(__dirname + '/../assetIdEncoder')

it('should return Unlocked asset ID from address', function (done) {
it('should return Unlocked asset ID from testnet address', function (done) {
bitcoinTransaction = {

@@ -129,2 +129,59 @@ cc_metadata:

it('should return Unlocked asset ID from mainnet address', function (done) {
bitcoinTransaction = {
cc_metadata:
[{
type: 'issuance',
lockStatus: false
}],
vin:
[{ txid: '095d3352d3c54b435d833be5d78016e3daa49b137a20c2941ed80214b519ecbe',
vout: 2,
address: '1PuKhp9CmFL9Xs2apKKeTAtLoZPcvoikE1'
}]
}
assetId3 = assetId(bitcoinTransaction)
assert.equal(assetId3[0], 'U', 'Should be Unlocked')
// console.log(assetId3)
done()
})
it('should return Unlocked asset ID from mainnet script address', function (done) {
bitcoinTransaction = {
cc_metadata:
[{
type: 'issuance',
lockStatus: false
}],
vin:
[{ txid: '095d3352d3c54b435d833be5d78016e3daa49b137a20c2941ed80214b519ecbe',
vout: 2,
address: '3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX'
}]
}
assetId3 = assetId(bitcoinTransaction)
assert.equal(assetId3[0], 'U', 'Should be Unlocked')
// console.log(assetId3)
done()
})
it('should return Unlocked asset ID from testnet script address', function (done) {
bitcoinTransaction = {
cc_metadata:
[{
type: 'issuance',
lockStatus: false
}],
vin:
[{ txid: '095d3352d3c54b435d833be5d78016e3daa49b137a20c2941ed80214b519ecbe',
vout: 2,
address: '2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc'
}]
}
assetId3 = assetId(bitcoinTransaction)
assert.equal(assetId3[0], 'U', 'Should be Unlocked')
// console.log(assetId3)
done()
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc