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