@@ -639,31 +639,35 @@ api.prototype.sendTransfer = function(seed, depth, minWeightMagnitude, transfers
639639* @param {object } params
640640* @param callback
641641*
642- * @returns
642+ * @returns { array } transaction objects
643643*/
644644api . prototype . promoteTransaction = function ( tail , depth , minWeightMagnitude , transfer , params , callback ) {
645645 var self = this ;
646646 if ( ! inputValidator . isHash ( tail ) ) {
647647 return callback ( errors . invalidTrytes ( ) ) ;
648648 }
649649
650- if ( ! self . isPromotable ( tail ) ) {
650+ self . isPromotable ( tail ) . then ( function ( isPromotable ) {
651+ if ( ! isPromotable ) {
651652 return callback ( errors . inconsistentSubtangle ( tail ) ) ;
652- }
653+ }
653654
654- if ( params . interrupt === true ) {
655- return callback ( null , tail ) ;
656- }
655+ if ( params . interrupt === true ) {
656+ return callback ( null , tail ) ;
657+ }
657658
658- self . sendTransfer ( transfer [ 0 ] . address , depth , minWeightMagnitude , transfer , { reference : tail } , function ( err , res ) {
659- if ( err == null && params . delay > 0 ) {
660- setTimeout ( function ( ) {
661- self . promoteTransaction ( tail , depth , minWeightMagnitude , transfer , params , callback ) ;
662- } , params . delay ) ;
663- } else {
664- return callback ( err , res ) ;
665- }
666- } ) ;
659+ self . sendTransfer ( transfer [ 0 ] . address , depth , minWeightMagnitude , transfer , { reference : tail } , function ( err , res ) {
660+ if ( err == null && params . delay > 0 ) {
661+ setTimeout ( function ( ) {
662+ self . promoteTransaction ( tail , depth , minWeightMagnitude , transfer , params , callback ) ;
663+ } , params . delay ) ;
664+ } else {
665+ return callback ( err , res ) ;
666+ }
667+ } ) ;
668+ } ) . catch ( function ( err ) {
669+ callback ( err )
670+ } )
667671}
668672
669673/**
@@ -1949,6 +1953,9 @@ api.prototype.isPromotable = function(tail) {
19491953
19501954 var promise = new Promise ( function ( res , rej ) {
19511955 self . sendCommand ( command , function ( err , isConsistent ) {
1956+ if ( err ) {
1957+ rej ( err )
1958+ }
19521959 res ( isConsistent . state ) ;
19531960 } ) ;
19541961 } ) ;
0 commit comments