git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: f879199c3cfb67185d4d4ae91f4ff03a55d831ba

Files: f879199c3cfb67185d4d4ae91f4ff03a55d831ba / address.js

519 bytesRaw
1const U256 = require('./u256.js')
2
3module.exports = class Address extends U256 {
4 constructor (value) {
5 super(value)
6 if (this._value.byteLength() > 20) {
7 throw new Error('Invalid address length: ' + this._value.byteLength() + ' for ' + value)
8 }
9 }
10
11 toBuffer () {
12 return super.toBuffer(20)
13 }
14
15 toString () {
16 return '0x' + this._value.toString('hex', 40)
17 }
18
19 isZero () {
20 return this._value.isZero()
21 }
22
23 equals (address) {
24 return this.toString() === address.toString()
25 }
26}
27

Built with git-ssb-web