@@ -505,10 +505,20 @@ API.prototype.createAddress = function(is_change, cb) {
505505} ;
506506
507507API . prototype . sendPayment = function ( asset , to_address , amount , arrSigningDeviceAddresses , recipient_device_address , cb ) {
508+ this . sendMultiPayment ( {
509+ asset : asset ,
510+ to_address : to_address ,
511+ amount : amount ,
512+ arrSigningDeviceAddresses : arrSigningDeviceAddresses ,
513+ recipient_device_address : recipient_device_address
514+ } , cb ) ;
515+ }
516+
517+ API . prototype . sendMultiPayment = function ( opts , cb ) {
508518 var self = this ;
509519 var coin = ( this . credentials . network == 'livenet' ? "0" : "1" ) ;
510520
511- var signWithLocalPrivateKey = function ( wallet_id , account , is_change , address_index , text_to_sign , handleSig ) {
521+ opts . signWithLocalPrivateKey = function ( wallet_id , account , is_change , address_index , text_to_sign , handleSig ) {
512522 var path = "m/44'/" + coin + "'/" + account + "'/" + is_change + "/" + address_index ;
513523 var xPrivKey = new Bitcore . HDPrivateKey . fromString ( self . credentials . xPrivKey ) ;
514524 var privateKey = xPrivKey . derive ( path ) . privateKey ;
@@ -519,15 +529,9 @@ API.prototype.sendPayment = function(asset, to_address, amount, arrSigningDevice
519529
520530 // create a new change address or select first unused one
521531 walletDefinedByKeys . issueOrSelectNextChangeAddress ( self . credentials . walletId , function ( objAddr ) {
522- var change_address = objAddr . address ;
523- walletDefinedByKeys . sendPaymentFromWallet (
524- asset , self . credentials . walletId , to_address , amount , change_address ,
525- arrSigningDeviceAddresses , recipient_device_address ,
526- signWithLocalPrivateKey ,
527- function ( err ) {
528- cb ( err ) ;
529- }
530- ) ;
532+ opts . change_address = objAddr . address ;
533+ opts . wallet = self . credentials . walletId ;
534+ walletDefinedByKeys . sendMultiPaymentFromWallet ( opts , cb ) ;
531535 } ) ;
532536} ;
533537
0 commit comments