From 5b7eb57d76a3ba7252b7937e78942a30d707ecc9 Mon Sep 17 00:00:00 2001 From: Brendon Duncan Date: Wed, 26 Sep 2018 15:12:37 +1200 Subject: [PATCH] Fix for sending ShapeShift transaction to Shapeshift deposit address, rather than own wallet. --- src/js/controllers/review.controller.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/js/controllers/review.controller.js b/src/js/controllers/review.controller.js index c6c484700..2490fc053 100644 --- a/src/js/controllers/review.controller.js +++ b/src/js/controllers/review.controller.js @@ -46,7 +46,7 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit vm.sendingTitle = gettextCatalog.getString('You are sending'); vm.sendStatus = ''; vm.showAddress = true; - vm.thirdParty = false; + vm.thirdParty = null; vm.wallet = null; vm.memoExpanded = false; @@ -270,6 +270,9 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit txp: {}, }; + if (vm.thirdParty && vm.thirdParty.id === "shapeshift") { + tx.toAddress = vm.thirdParty.toAddress; + } if (data.stateParams.requiredFeeRate) { vm.usingMerchantFee = true; @@ -283,7 +286,14 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit var B = tx.coin === 'bch' ? bitcoreCash : bitcore; var networkName; try { - if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer + // Final destination is a wallet, but this transaction must go to an address for the first stage of the exchange. + if (sendFlowData.thirdParty && sendFlowData.thirdParty.id === 'shapeshift') { + networkName = (new B.Address(tx.toAddress)).network.name; + tx.network = networkName; + console.log('calling setupTx() for shapeshift.'); + setupTx(tx); + + } else if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer ongoingProcess.set('generatingNewAddress', true); var toWallet = profileService.getWallet(destinationWalletId); @@ -498,9 +508,6 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit function initShapeshift(cb) { vm.sendingTitle = gettextCatalog.getString('You are shifting'); - if (!vm.thirdParty.data) { - vm.thirdParty.data = {}; - } var toWallet = profileService.getWallet(destinationWalletId); vm.destination.name = toWallet.name; @@ -525,9 +532,8 @@ function reviewController(addressbookService, bitcoinCashJsService, bitcore, bit if (err) { return cb(err); } else { - vm.destination.kind = 'shapeshift'; - vm.destination.address = toAddress; - tx.toAddress = shapeshiftData.toAddress; + // Want it to appear like a wallet-to-wallet transfer, so don't set the main toAddress. + vm.thirdParty.toAddress = shapeshiftData.toAddress; vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId; vm.memoExpanded = !!vm.memo; ongoingProcess.set('connectingShapeshift', false);