mirror of https://github.com/BTCPrivate/copay.git
Check tx proposal minimum amount
This commit is contained in:
parent
cfc284af75
commit
ce910fe52f
|
@ -11,7 +11,8 @@ var defaultConfig = {
|
||||||
// wallet limits
|
// wallet limits
|
||||||
limits: {
|
limits: {
|
||||||
totalCopayers: 12,
|
totalCopayers: 12,
|
||||||
mPlusN: 100
|
mPlusN: 100,
|
||||||
|
minAmountSatoshi: 5400,
|
||||||
},
|
},
|
||||||
|
|
||||||
// network layer (PeerJS) config
|
// network layer (PeerJS) config
|
||||||
|
|
|
@ -8,6 +8,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
var satToUnit = 1 / config.unitToSatoshi;
|
var satToUnit = 1 / config.unitToSatoshi;
|
||||||
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
|
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
|
||||||
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
|
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
|
||||||
|
$scope.minAmount = config.limits.minAmountSatoshi * satToUnit;
|
||||||
|
|
||||||
$scope.loadTxs = function() {
|
$scope.loadTxs = function() {
|
||||||
var opts = {
|
var opts = {
|
||||||
|
|
|
@ -1534,6 +1534,7 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
|
||||||
preconditions.checkArgument(new Address(toAddress).network().name === this.getNetworkName(), 'networkname mismatch');
|
preconditions.checkArgument(new Address(toAddress).network().name === this.getNetworkName(), 'networkname mismatch');
|
||||||
preconditions.checkState(pkr.isComplete(), 'pubkey ring incomplete');
|
preconditions.checkState(pkr.isComplete(), 'pubkey ring incomplete');
|
||||||
preconditions.checkState(priv, 'no private key');
|
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 (comment) preconditions.checkArgument(comment.length <= 100);
|
||||||
|
|
||||||
if (!opts.remainderOut) {
|
if (!opts.remainderOut) {
|
||||||
|
|
|
@ -630,7 +630,7 @@ describe('Wallet model', function() {
|
||||||
return utxo;
|
return utxo;
|
||||||
};
|
};
|
||||||
var toAddress = 'mjfAe7YrzFujFf8ub5aUrCaN5GfSABdqjh';
|
var toAddress = 'mjfAe7YrzFujFf8ub5aUrCaN5GfSABdqjh';
|
||||||
var amountSatStr = '1000';
|
var amountSatStr = '10000';
|
||||||
|
|
||||||
it('should create transaction', function(done) {
|
it('should create transaction', function(done) {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
|
@ -641,6 +641,7 @@ describe('Wallet model', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create & sign transaction from received funds', function(done) {
|
it('should create & sign transaction from received funds', function(done) {
|
||||||
var k2 = new PrivateKey({
|
var k2 = new PrivateKey({
|
||||||
networkName: config.networkName
|
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() {
|
describe('#send', function() {
|
||||||
it('should call this.network.send', function() {
|
it('should call this.network.send', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
<input type="number" id="amount"
|
<input type="number" id="amount"
|
||||||
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError"
|
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError"
|
||||||
name="amount" placeholder="Amount" ng-model="amount"
|
name="amount" placeholder="Amount" ng-model="amount"
|
||||||
min="0.00005400" max="10000000000" enough-amount required
|
min="{{minAmount}}" max="10000000000" enough-amount required
|
||||||
autocomplete="off"
|
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 && amount"><i class="fi-check"></i></small>
|
||||||
|
|
Loading…
Reference in New Issue