File tree Expand file tree Collapse file tree 4 files changed +28
-0
lines changed Expand file tree Collapse file tree 4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ ECPair.prototype.getAddress = function () {
105105 return bs58check . encode ( payload )
106106}
107107
108+ ECPair . prototype . getNetwork = function ( ) {
109+ return this . network
110+ }
111+
108112ECPair . prototype . getPublicKeyBuffer = function ( ) {
109113 return this . Q . getEncoded ( this . compressed )
110114}
Original file line number Diff line number Diff line change @@ -136,6 +136,10 @@ HDNode.prototype.getFingerprint = function () {
136136 return this . getIdentifier ( ) . slice ( 0 , 4 )
137137}
138138
139+ HDNode . prototype . getNetwork = function ( ) {
140+ return this . keyPair . getNetwork ( )
141+ }
142+
139143HDNode . prototype . getPublicKeyBuffer = function ( ) {
140144 return this . keyPair . getPublicKeyBuffer ( )
141145}
Original file line number Diff line number Diff line change @@ -167,6 +167,17 @@ describe('ECPair', function () {
167167 } )
168168 } )
169169
170+ describe ( 'getNetwork' , function ( ) {
171+ fixtures . valid . forEach ( function ( f ) {
172+ it ( 'returns ' + f . network + ' for ' + f . WIF , function ( ) {
173+ var network = NETWORKS [ f . network ]
174+ var keyPair = ECPair . fromWIF ( f . WIF , NETWORKS_LIST )
175+
176+ assert . strictEqual ( keyPair . getNetwork ( ) , network )
177+ } )
178+ } )
179+ } )
180+
170181 describe ( 'ecdsa wrappers' , function ( ) {
171182 var keyPair , hash
172183
Original file line number Diff line number Diff line change @@ -121,6 +121,15 @@ describe('HDNode', function () {
121121 } ) )
122122 } )
123123
124+ describe ( 'getNetwork' , function ( ) {
125+ it ( 'wraps keyPair.getNetwork' , sinon . test ( function ( ) {
126+ this . mock ( keyPair ) . expects ( 'getNetwork' )
127+ . once ( ) . withArgs ( ) . returns ( 'network' )
128+
129+ assert . strictEqual ( hd . getNetwork ( ) , 'network' )
130+ } ) )
131+ } )
132+
124133 describe ( 'getPublicKeyBuffer' , function ( ) {
125134 it ( 'wraps keyPair.getPublicKeyBuffer' , sinon . test ( function ( ) {
126135 this . mock ( keyPair ) . expects ( 'getPublicKeyBuffer' )
You can’t perform that action at this time.
0 commit comments