settings: fix send in livenet
This commit is contained in:
parent
dcb78847d2
commit
c47318c728
4 changed files with 14 additions and 10 deletions
|
|
@ -30,14 +30,14 @@ angular.module('copayApp.directives')
|
||||||
// Bip21 uri
|
// Bip21 uri
|
||||||
if (/^bitcoin:/.test(value)) {
|
if (/^bitcoin:/.test(value)) {
|
||||||
var uri = new bitcore.BIP21(value);
|
var uri = new bitcore.BIP21(value);
|
||||||
var hasAddress = uri.address && uri.isValid() && uri.address.network().name === config.networkName;
|
var hasAddress = uri.address && uri.isValid() && uri.address.network().name === $rootScope.wallet.getNetworkName();
|
||||||
ctrl.$setValidity('validAddress', uri.data.merchant || hasAddress);
|
ctrl.$setValidity('validAddress', uri.data.merchant || hasAddress);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular Address
|
// Regular Address
|
||||||
var a = new Address(value);
|
var a = new Address(value);
|
||||||
ctrl.$setValidity('validAddress', a.isValid() && a.network().name === config.networkName);
|
ctrl.$setValidity('validAddress', a.isValid() && a.network().name === $rootScope.wallet.getNetworkName());
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,5 +122,9 @@ FakeWallet.prototype.toEncryptedObj = function() {
|
||||||
|
|
||||||
FakeWallet.prototype.close = function() {};
|
FakeWallet.prototype.close = function() {};
|
||||||
|
|
||||||
|
FakeWallet.prototype.getNetworkName = function() {
|
||||||
|
return 'testnet';
|
||||||
|
};
|
||||||
|
|
||||||
// TODO a try catch was here
|
// TODO a try catch was here
|
||||||
module.exports = FakeWallet;
|
module.exports = FakeWallet;
|
||||||
|
|
|
||||||
|
|
@ -42,16 +42,16 @@ describe("Unit: Testing Directives", function() {
|
||||||
form = $scope.form;
|
form = $scope.form;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should validate with network', function() {
|
it('should validate with network', inject(function($rootScope) {
|
||||||
config.networkName = 'testnet';
|
$rootScope.wallet.getNetworkName = sinon.stub().returns('testnet');
|
||||||
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
||||||
expect(form.address.$invalid).to.equal(false);
|
expect(form.address.$invalid).to.equal(false);
|
||||||
});
|
}));
|
||||||
it('should not validate with other network', function() {
|
it('should not validate with other network', inject(function($rootScope) {
|
||||||
config.networkName = 'livenet';
|
$rootScope.wallet.getNetworkName = sinon.stub().returns('livenet');
|
||||||
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
form.address.$setViewValue('mkfTyEk7tfgV611Z4ESwDDSZwhsZdbMpVy');
|
||||||
expect(form.address.$invalid).to.equal(true);
|
expect(form.address.$invalid).to.equal(true);
|
||||||
});
|
}));
|
||||||
it('should not validate random', function() {
|
it('should not validate random', function() {
|
||||||
form.address.$setViewValue('thisisaninvalidaddress');
|
form.address.$setViewValue('thisisaninvalidaddress');
|
||||||
expect(form.address.$invalid).to.equal(true);
|
expect(form.address.$invalid).to.equal(true);
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@
|
||||||
<div class="row collapse">
|
<div class="row collapse">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<div class="row collapse">
|
<div class="row collapse">
|
||||||
<label for="address"><span translate>To address</span>
|
<label for="address"><span translate>To:</span>
|
||||||
<small translate ng-hide="!sendForm.address.$pristine || address">required</small>
|
<small translate ng-hide="!sendForm.address.$pristine || address">required</small>
|
||||||
<small translate class="is-valid" ng-show="!sendForm.address.$invalid && address">valid!</small>
|
<small translate class="is-valid" ng-show="!sendForm.address.$invalid && address">valid!</small>
|
||||||
<small translate class="has-error" ng-show="sendForm.address.$invalid && address">not valid</small>
|
<small translate class="has-error" ng-show="sendForm.address.$invalid && address">not valid</small>
|
||||||
</label>
|
</label>
|
||||||
<div class="small-10 columns">
|
<div class="small-10 columns">
|
||||||
<input type="text" id="address" name="address" ng-disabled="loading || !!$root.merchant"
|
<input type="text" id="address" name="address" ng-disabled="loading || !!$root.merchant"
|
||||||
placeholder="{{'Send to'|translate}}" ng-model="address" ng-change="onChanged()" valid-address required>
|
placeholder="{{'Bitcoin address'|translate}}" ng-model="address" ng-change="onChanged()" valid-address required>
|
||||||
<small class="icon-input" ng-show="!sendForm.address.$invalid && address"><i class="fi-check"></i></small>
|
<small class="icon-input" ng-show="!sendForm.address.$invalid && address"><i class="fi-check"></i></small>
|
||||||
<small class="icon-input" ng-show="sendForm.address.$invalid && address"><i class="fi-x"></i></small>
|
<small class="icon-input" ng-show="sendForm.address.$invalid && address"><i class="fi-x"></i></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue