Merge pull request #1350 from isocolsky/fix/min_amount

removed min amount check
This commit is contained in:
Gustavo Maximiliano Cortez 2014-09-10 15:36:48 -03:00
commit cb658df199
5 changed files with 72 additions and 89 deletions

View File

@ -16,7 +16,6 @@ var defaultConfig = {
limits: {
totalCopayers: 12,
mPlusN: 100,
minAmountSatoshi: 5400,
},
// network layer config

View File

@ -9,7 +9,6 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
$scope.unitToSatoshi = config.unitToSatoshi;
$scope.minAmount = config.limits.minAmountSatoshi * satToUnit;
$scope.alternativeName = config.alternativeName;
$scope.alternativeIsoCode = config.alternativeIsoCode;
@ -37,8 +36,7 @@ angular.module('copayApp.controllers').controller('SendController',
this._alternative = newValue;
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
this._amount = parseFloat(
(rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit
).toFixed(config.unitDecimals), 10);
(rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit).toFixed(config.unitDecimals), 10);
} else {
this._amount = 0;
}
@ -55,8 +53,7 @@ angular.module('copayApp.controllers').controller('SendController',
this._amount = newValue;
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
this._alternative = parseFloat(
(rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode)
).toFixed(2), 10);
(rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode)).toFixed(2), 10);
} else {
this._alternative = 0;
}
@ -187,9 +184,7 @@ angular.module('copayApp.controllers').controller('SendController',
}
// If we're setting the domain, ignore the change.
if ($rootScope.merchant
&& $rootScope.merchant.domain
&& address === $rootScope.merchant.domain) {
if ($rootScope.merchant && $rootScope.merchant.domain && address === $rootScope.merchant.domain) {
uri = {
merchant: $rootScope.merchant.request_url
};
@ -480,9 +475,7 @@ angular.module('copayApp.controllers').controller('SendController',
var uri;
// If we're setting the domain, ignore the change.
if ($rootScope.merchant
&& $rootScope.merchant.domain
&& value === $rootScope.merchant.domain) {
if ($rootScope.merchant && $rootScope.merchant.domain && value === $rootScope.merchant.domain) {
return;
}
@ -566,9 +559,7 @@ angular.module('copayApp.controllers').controller('SendController',
var val = scope.sendForm.address.$viewValue || '';
var uri;
// If we're setting the domain, ignore the change.
if ($rootScope.merchant
&& $rootScope.merchant.domain
&& val === $rootScope.merchant.domain) {
if ($rootScope.merchant && $rootScope.merchant.domain && val === $rootScope.merchant.domain) {
uri = {
merchant: $rootScope.merchant.request_url
};

View File

@ -2114,7 +2114,6 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
preconditions.checkArgument(new Address(toAddress).network().name === this.getNetworkName(), 'networkname mismatch');
preconditions.checkState(pkr.isComplete(), 'pubkey ring incomplete');
preconditions.checkState(priv, 'no private key');
preconditions.checkArgument(bignum(amountSatStr, 10).cmp(copayConfig.limits.minAmountSatoshi) >= 0, 'invalid amount');
if (comment) preconditions.checkArgument(comment.length <= 100);
if (!opts.remainderOut) {

View File

@ -765,7 +765,11 @@ describe('Wallet model', function() {
var txp = w.txProposals.get(ntxid);
// Assign fake builder
txp.builder = new Builder();
sinon.stub(txp.builder, 'build').returns({ isComplete: function () { return false; }});
sinon.stub(txp.builder, 'build').returns({
isComplete: function() {
return false;
}
});
(function() {
w.sendTx(ntxid);
}).should.throw('Tx is not complete. Can not broadcast');
@ -777,7 +781,9 @@ describe('Wallet model', function() {
var utxo = createUTXO(w);
w.blockchain.fixUnspent(utxo);
w.createTx(toAddress, amountSatStr, null, function(err, ntxid) {
sinon.stub(w.blockchain, 'broadcast').yields({statusCode: 303});
sinon.stub(w.blockchain, 'broadcast').yields({
statusCode: 303
});
var spyCheckSentTx = sinon.spy(w, '_checkSentTx');
w.sendTx(ntxid, function() {});
chai.expect(spyCheckSentTx.calledOnce).to.be.true;
@ -823,23 +829,6 @@ describe('Wallet model', function() {
});
});
describe('#createTxSync', function() {
it('should fail if amount below min value', function() {
var w = cachedCreateW2();
var utxo = createUTXO(w);
var badCreate = function() {
w.createTxSync(
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
'123',
null,
utxo
);
}
chai.expect(badCreate).to.throw('invalid amount');
});
});
describe('removeTxWithSpentInputs', function() {
it('should remove pending TxProposal with spent inputs', function(done) {
var w = cachedCreateW2();
@ -904,7 +893,9 @@ describe('Wallet model', function() {
// Simulate input spent. txp should be removed from txps list
w.blockchain.fixUnspent([]);
var txp = w.txProposals.get(ntxid);
sinon.stub(txp, 'isPending', function () { return false; })
sinon.stub(txp, 'isPending', function() {
return false;
})
w.removeTxWithSpentInputs();
chai.expect(w.getTxProposals().length).to.equal(1);
@ -1402,7 +1393,9 @@ describe('Wallet model', function() {
};
var s1 = sinon.stub(w, '_getKeyMap', function() {
return {1:2};
return {
1: 2
};
});
var s2 = sinon.stub(w.txProposals, 'merge', function() {
@ -1412,7 +1405,9 @@ describe('Wallet model', function() {
return {
ntxid: 1,
txp: {
setCopayers: function() {return ['oeoe']; } ,
setCopayers: function() {
return ['oeoe'];
},
},
new: response == 1
};

View File

@ -70,9 +70,8 @@
<input type="number" id="amount"
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError"
name="amount" placeholder="{{'Amount'|translate}}" ng-model="amount"
min="{{minAmount}}" max="10000000000" enough-amount required
autocomplete="off"
>
min="0.00000001" max="10000000000" enough-amount required
autocomplete="off">
<small class="icon-input" ng-show="!sendForm.amount.$invalid && amount"><i class="fi-check"></i></small>
<small class="icon-input" ng-show="sendForm.amount.$invalid && !sendForm.amount.$pristine && !notEnoughAmount"><i class="fi-x"></i></small>
<a class="small input-note" title="{{'Send all funds'|translate}}"