@@ -150,16 +150,16 @@ 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 ,
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 ) {
153
+ getFromNode ( 'http://' + server + '/api/accounts?address=' + senderAddress , function ( err , response , body ) {
154
+
155
+ if ( ! err && body ) {
156
+ try {
157
+ body = JSON . parse ( body ) ;
158
+ if ( ! body . hasOwnProperty ( 'success' ) || body . success === false ) {
159
+ // The account does not yet exist on the connected node.
160
+ throw "Failed: " + body . error ;
161
+ }
162
+ if ( body . hasOwnProperty ( 'account' ) && body . account . secondSignature ) {
163
163
container . prompt ( {
164
164
type : 'password' ,
165
165
name : 'passphrase' ,
@@ -169,16 +169,16 @@ function postTransaction(container, transaction, cb){
169
169
var secondKeys = arkjs . crypto . getKeys ( result . passphrase ) ;
170
170
arkjs . crypto . secondSign ( transaction , secondKeys ) ;
171
171
transaction . id = arkjs . crypto . getId ( transaction ) ;
172
-
173
172
} else {
174
- vorpal . log ( 'No second passphrase given. Trying without.' ) ;
175
-
173
+ vorpal . log ( 'No second passphrase given. Trying without.' ) ;
176
174
}
177
175
} ) ;
178
- }
179
- performPost ( ) ;
180
- } // if(body)
181
- } // if(err)
176
+ }
177
+ } catch ( error ) {
178
+ vorpal . log ( colors . red ( error ) ) ;
179
+ }
180
+ } // if(body)
181
+ performPost ( ) ;
182
182
} ) ;
183
183
}
184
184
0 commit comments