https://github.com/bitcoinjs/bip68
A BIP68 relative lock-time encoding library.
https://github.com/bitcoinjs/bip68
bip68 bitcoin
Last synced: 11 months ago
JSON representation
A BIP68 relative lock-time encoding library.
- Host: GitHub
- URL: https://github.com/bitcoinjs/bip68
- Owner: bitcoinjs
- License: mit
- Created: 2017-11-30T05:32:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-11T05:24:58.000Z (almost 8 years ago)
- Last Synced: 2025-07-09T14:50:50.890Z (12 months ago)
- Topics: bip68, bitcoin
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bip68
[](https://www.npmjs.org/package/bip68)
[](https://travis-ci.org/bitcoinjs/bip68)
[](https://github.com/feross/standard)
A [BIP68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki) relative lock-time encoding library.
## Example
``` javascript
let bip68 = require('bip68')
bip68.encode({ seconds: 2048 })
// => 0x00400004
bip68.encode({ seconds: 102 })
// => TypeError: Expected Number seconds as a multiple of 512 (as per the BIP)
bip68.encode({ blocks: 54 })
// => 0x00000036
bip68.encode({ blocks: 200 })
// => 0x000000c8
bip68.decode(0x03ffffff)
// => { seconds: 33553920 }
bip68.decode(0x0100fffe) // safely ignores extension bits
// => { blocks: 65534 }
bip68.decode(0xffffffff) // final sequence
// => {}
```
## LICENSE [ISC](LICENSE)