git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: d40898a1c0e4f37c6b28da6da6646db86398ebcb

Files: d40898a1c0e4f37c6b28da6da6646db86398ebcb / 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