Check tx proposal minimum amount

This commit is contained in:
Ivan Socolsky 2014-08-21 16:02:02 -03:00
parent cfc284af75
commit ce910fe52f
5 changed files with 24 additions and 3 deletions

View File

@ -11,7 +11,8 @@ var defaultConfig = {
// wallet limits
limits: {
totalCopayers: 12,
mPlusN: 100
mPlusN: 100,
minAmountSatoshi: 5400,
},
// network layer (PeerJS) config

View File

@ -8,6 +8,7 @@ angular.module('copayApp.controllers').controller('SendController',
var satToUnit = 1 / config.unitToSatoshi;
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
$scope.minAmount = config.limits.minAmountSatoshi * satToUnit;
$scope.loadTxs = function() {
var opts = {

View File

@ -1534,6 +1534,7 @@ 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

@ -630,7 +630,7 @@ describe('Wallet model', function() {
return utxo;
};
var toAddress = 'mjfAe7YrzFujFf8ub5aUrCaN5GfSABdqjh';
var amountSatStr = '1000';
var amountSatStr = '10000';
it('should create transaction', function(done) {
var w = cachedCreateW2();
@ -641,6 +641,7 @@ describe('Wallet model', function() {
done();
});
});
it('should create & sign transaction from received funds', function(done) {
var k2 = new PrivateKey({
networkName: config.networkName
@ -724,6 +725,23 @@ 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('#send', function() {
it('should call this.network.send', function() {
var w = cachedCreateW2();

View File

@ -67,7 +67,7 @@
<input type="number" id="amount"
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError"
name="amount" placeholder="Amount" ng-model="amount"
min="0.00005400" max="10000000000" enough-amount required
min="{{minAmount}}" max="10000000000" enough-amount required
autocomplete="off"
>
<small class="icon-input" ng-show="!sendForm.amount.$invalid && amount"><i class="fi-check"></i></small>