Skip to content

Commit

Permalink
Tested address parsing with optional 1W prefix.
Browse files Browse the repository at this point in the history
Removed duplicate amount check.
  • Loading branch information
beregovoy68 committed Jun 21, 2016
1 parent 2b6f378 commit 6b8d10c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
3 changes: 1 addition & 2 deletions js/waves.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,7 @@ var Waves = (function(Waves, $, undefined) {
}
});
$.validator.addMethod('address', function(value, element){
return this.optional(element) || Waves.Addressing.validateDisplayAddress(value) ||
Waves.Addressing.validateRawAddress(value);
return this.optional(element) || Waves.Addressing.validateDisplayAddress(value);
}, "Account number must be a sequence of 35 alphanumeric characters with no spaces, optionally starting with '1W'");
$.validator.addMethod('decimal', function(value, element) {
return this.optional(element) || /^(?:-?\d+)?(?:\.\d+)?$/.test(value);
Expand Down
19 changes: 3 additions & 16 deletions js/waves.ui.wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var Waves = (function(Waves, $, undefined) {
maxSend = maxSend / Math.pow(10,8);
var sendAmount = Number($("#wavessendamount").val().replace(/\s+/g, ''));

if(sendAmount > maxSend) {
if (sendAmount > maxSend) {
$.growl.error({ message: 'Error: Not enough funds' });
return;
}
Expand All @@ -118,16 +118,8 @@ var Waves = (function(Waves, $, undefined) {
var senderPublic = Base58.decode(Waves.publicKey);
var senderPrivate = Base58.decode(Waves.privateKey);
var addressText = $("#wavesrecipient").val().replace(/\s+/g, '');
var recipient = undefined;
if (Waves.Addressing.validateDisplayAddress(addressText))
recipient = Waves.Addressing.fromDisplayAddress(addressText);
else if (Waves.Addressing.validateRawAddress(addressText))
recipient = Waves.Addressing.fromRawAddress(addressText);
else {
// we shouldn't see this message, because form is validated
$.growl.error({ message: 'Unknown address format' });
return;
}
// validate display address knows that the address prefix is optional
var recipient = Waves.Addressing.fromDisplayAddress(addressText);

var wavesTime = Number(Waves.getTime());

Expand All @@ -138,11 +130,6 @@ var Waves = (function(Waves, $, undefined) {

//var verify = Waves.curve25519.verify(senderPublic, signatureData, Base58.decode(signature));

if(sendAmount > maxSend) {
$.growl.error({ message: 'Error: Not enough funds' });
return;
}

var data = {
"recipient": recipient.getRawAddress(),
"timestamp": wavesTime,
Expand Down

0 comments on commit 6b8d10c

Please sign in to comment.