 
   sweepPrivateKey: ({privateKey, account, txFee}, callback) ->
     txFee ?= 10000
-    completion = new CompletionClosure(callback)
+    d = ledger.defer(callback)
     recipientAddress = account.getHDAccount().getCurrentPublicAddress()
     ecKey = new window.bitcoin.ECKey.fromWIF(privateKey)
     publicKey = ecKey.pub.getAddress().toString()
     addresses = [publicKey]
 
     ledger.api.UnspentOutputsRestClient.instance.getUnspentOutputsFromAddresses addresses , (outputs, error) ->
-      return completion.failure(error) if error?
+      return d.reject(error) if error?
 
       txBuilder = new window.bitcoin.TransactionBuilder()
       amountToSend = new ledger.wallet.Value()


        if hasNext is false and amountToSend.lte(txFee)
          # Not enough available funds
          completion.failure(new ledger.StandardError(ledger.errors.NotEnoughFunds))
        else if hasNext is false
          amountToSend = amountToSend.subtract(10000)
          txBuilder.addOutput(recipientAddress, amountToSend.toNumber())

          txBuilder.sign(index, ecKey) for input, index in txBuilder.tx.ins
          txHex = txBuilder.build().toHex()
          ledger.api.TransactionsRestClient.instance.postTransactionHex txHex, (txHash, error) =>
            d.resolve(txHash, error)
        else
          # Continue to collect funds
          do done
    d.promise