it('with proportional amounts for each payee', function (done) {
      var amt1 = bitcore.Unit.fromBTC(0.017 - processor.fee * 0.2).satoshis
      var amt2 = bitcore.Unit.fromBTC(0.068 - processor.fee * 0.8).satoshis

      processor.distribute(payees, function () {
        expect(transaction.to).to.have.been.calledWith(a1, amt1)
        expect(transaction.to).to.have.been.calledWith(a2, amt2)
        done()
      })
    })
示例#2
0
文件: bitcoin.js 项目: Nouhi/DogeNFC
        return $q(function deferred(resolve, reject) {

          var conversions
            , conversionsLength
            , conversionsIndex = 0
            , aConversion
            , theActualRate;
          if (!ratesCache.get('conversions')) {

            $http({
              'method': 'GET',
              'url': 'https://bitpay.com/api/rates'
            }).then(function onSuccess(response) {

              if (response &&
                response.data) {

                conversions = response.data;
                conversionsLength = conversions.length;
                ratesCache.put('conversions', conversions);
                for (; conversionsIndex < conversionsLength; conversionsIndex += 1) {

                  aConversion = conversions[conversionsIndex];
                  if (aConversion &&
                    aConversion.code === currentCurrency) {

                    theActualRate = aConversion.rate;
                  }
                }

                resolve(bitcore.Unit.fromSatoshis(amount).atRate(theActualRate));
              }
            }, function onFailure(failure) {

              reject(failure);
            });
          } else {

            conversions = ratesCache.get('conversions');
            conversionsLength = conversions.length;
            for (; conversionsIndex < conversionsLength; conversionsIndex += 1) {

              aConversion = conversions[conversionsIndex];
              if (aConversion &&
                aConversion.code === currentCurrency) {

                theActualRate = aConversion.rate;
              }
            }

            resolve(bitcore.Unit.fromSatoshis(amount).atRate(theActualRate));
          }
        });
示例#3
0
文件: bitcoin.js 项目: Nouhi/DogeNFC
            }).then(function onSuccess(response) {

              if (response &&
                response.data) {

                conversions = response.data;
                conversionsLength = conversions.length;
                ratesCache.put('conversions', conversions);
                for (; conversionsIndex < conversionsLength; conversionsIndex += 1) {

                  aConversion = conversions[conversionsIndex];
                  if (aConversion &&
                    aConversion.code === currentCurrency) {

                    theActualRate = aConversion.rate;
                  }
                }

                resolve(bitcore.Unit.fromSatoshis(amount).atRate(theActualRate));
              }
            }, function onFailure(failure) {