Burn-Payment-Encoder
Payment-Encoder provides the encode/decode functions between a Colored Coins burn-transaction payment Object to buffer
Installation
$ npm install cc-burn-payment-encoder
Encode
Params:
paymentObject
- A standard Colored Coins payment object with the following properties:
{
skip: "Boolean"
range: "Boolean"
percent: "Boolean"
output: "Number"
amount: "Number"
burn: "Boolean"
}
Returns a new Buffer holding the encoded payment.
Example:
var paymentEncode = require('cc-burn-payment-encoder')
var paymentObject = {
skip: false,
range: false,
percent: true,
output: 1,
amount: 321321321
}
var code = paymentEncode.encode(paymentObject)
console.log(code)
Alternatively, you can encode a "burn" payment:
var paymentObject = {
skip: false,
percent: false,
amount: 13,
burn: true
}
var code = paymentEncode.encode(paymentObject)
console.log(code)
Decode
Params:
- consume - takes a consumable buffer (You can use buffer-consumer like in the example to create one)
Returns a Colored Coins payment Object
Example:
var paymentEncode = require('cc-burn-payment-encoder')
var consumer = require('buffer-consumer')
var decode = paymentEncode.decode(consumer(code))
var codeBuffer = new Buffer([0x82,0x76,0x0e,0x1b,0x48])
console.log(paymentEncode.decode(consumer(codeBuffer)))
Testing
In order to test you need to install mocha globaly on your machine
$ cd /"module-path"/cc-burn-payment-encoder
$ mocha
License
Apache-2.0