@@ -150,29 +150,35 @@ function postTransaction(container, transaction, cb){
150
150
} ;
151
151
152
152
let senderAddress = arkjs . crypto . getAddress ( transaction . senderPublicKey ) ;
153
- getFromNode ( 'http://' + server + '/api/accounts?address=' + senderAddress , function ( err , response , body ) {
154
- if ( body ) {
155
- body = JSON . parse ( body ) ;
156
- if ( body . account . secondSignature ) {
157
- container . prompt ( {
158
- type : 'password' ,
159
- name : 'passphrase' ,
160
- message : 'Second passphrase: ' ,
161
- } , function ( result ) {
162
- if ( result . passphrase ) {
163
- var secondKeys = arkjs . crypto . getKeys ( result . passphrase ) ;
164
- arkjs . crypto . secondSign ( transaction , secondKeys ) ;
165
- transaction . id = arkjs . crypto . getId ( transaction ) ;
153
+ getFromNode ( 'http://' + server + '/api/accounts?address=' + senderAddress ,
154
+ function ( err , response , body ) {
155
+ // handle the potential error
156
+ if ( err ) {
157
+ vorpal . log ( 'Someting went wrong: ' + err ) ;
158
+
159
+ } else {
160
+ if ( body ) {
161
+ body = JSON . parse ( body ) ;
162
+ if ( body . account . secondSignature ) {
163
+ container . prompt ( {
164
+ type : 'password' ,
165
+ name : 'passphrase' ,
166
+ message : 'Second passphrase: ' ,
167
+ } , function ( result ) {
168
+ if ( result . passphrase ) {
169
+ var secondKeys = arkjs . crypto . getKeys ( result . passphrase ) ;
170
+ arkjs . crypto . secondSign ( transaction , secondKeys ) ;
171
+ transaction . id = arkjs . crypto . getId ( transaction ) ;
166
172
167
- } else {
168
- vorpal . log ( 'No second passphrase given. Trying without.' ) ;
173
+ } else {
174
+ vorpal . log ( 'No second passphrase given. Trying without.' ) ;
169
175
170
- }
171
- } ) ;
172
-
173
- }
174
- performPost ( ) ;
175
- }
176
+ }
177
+ } ) ;
178
+ }
179
+ performPost ( ) ;
180
+ } // if(body)
181
+ } // if(err)
176
182
} ) ;
177
183
}
178
184
0 commit comments