diff --git a/CMakeLists.txt b/CMakeLists.txt index 4836e99..11da06b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ target_link_libraries(${PROJECT_NAME} mysqlpp mysqlclient easylogging + readline ${Boost_LIBRARIES} pthread unbound diff --git a/html/js/controllers/login.js b/html/js/controllers/login.js index 7957bad..bf994b5 100755 --- a/html/js/controllers/login.js +++ b/html/js/controllers/login.js @@ -37,6 +37,9 @@ thinwalletCtrls.controller("LoginCtrl", function($scope, $location, AccountServi $scope.mnemonic_language = 'english'; + // just some dummy account, as not to fill login form every time. + $scope.mnemonic = "daft mouth scenic irate origin island irritate eternal ablaze template hotel boxes suitcase oilfield jury dash folding gymnast titans toolbox hiker archer hexagon hijack irate"; + var decode_seed = function(mnemonic, language) { diff --git a/html/js/controllers/receive_coins.js b/html/js/controllers/receive_coins.js index 0b642d6..6592170 100755 --- a/html/js/controllers/receive_coins.js +++ b/html/js/controllers/receive_coins.js @@ -26,34 +26,90 @@ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -thinwalletCtrls.controller('ReceiveCoinsCtrl', function($scope, $rootScope, AccountService, EVENT_CODES) { +thinwalletCtrls.controller('ReceiveCoinsCtrl', function($scope, AccountService, EVENT_CODES) { "use strict"; - $scope.accountService = AccountService; + // $scope.accountService = AccountService; - $scope.params = { - address: $scope.address + // $scope.params = { + // address: $scope.address + // }; + // // Generate random payment id + // $scope.payment_id = cnUtil.rand_32(); + + $scope.error = ""; + + + var strpad = function(org_str, padString, length) + { // from http://stackoverflow.com/a/10073737/248823 + var str = org_str; + while (str.length < length) + str = padString + str; + return str; }; - // Generate random payment id - $scope.payment_id = cnUtil.rand_32(); - // - //var payment_id8 = rand_8(); - //var integarted_address = get_account_integrated_address(keys.public_addr, payment_id8); + var public_address = AccountService.getAddress(); + + $scope.payment_id8 = rand_8(); // random 8 byte payment id + $scope.payment_id8_rendered = $scope.payment_id8; + + $scope.integarted_address = get_account_integrated_address( + public_address, $scope.payment_id8); + + $scope.$watch("payment_id8", function (newValue, oldValue) { + + if (oldValue !== newValue) + { + + var payment_id8 = $scope.payment_id8; - $scope.$watch( - function(scope) { - return { - address: scope.address, - label: scope.label, - payment_id: scope.payment_id, - message: scope.message, - amount: scope.amount - }; - }, - function(data) { - $scope.params = data; - }, + if (payment_id8.length <= 16 && /^[0-9a-fA-F]+$/.test(payment_id8)) { + // if payment id is shorter, but has correct number, just + // pad it to required length with zeros + payment_id8 = strpad(payment_id8, "0", 16); + } + + // now double check if ok, when we padded it + if (payment_id8.length !== 16 || !(/^[0-9a-fA-F]{16}$/.test(payment_id8))) + { + $scope.integarted_address = "Not avaliable due to error" + $scope.error = "The payment ID you've entered is not valid"; + return; + } + + $scope.integarted_address = get_account_integrated_address( + public_address, payment_id8); + + $scope.payment_id8_rendered = payment_id8; + + $scope.error = ""; + } + }, true ); + + $scope.new_payment_id8 = function() + { + $scope.payment_id8 = rand_8(); + } + + // + //var payment_id8 = rand_8(); + //var integarted_address = get_account_integrated_address(keys.public_addr, payment_id8); + + // $scope.$watch( + // function(scope) { + // return { + // address: scope.address, + // label: scope.label, + // payment_id: scope.payment_id, + // message: scope.message, + // amount: scope.amount + // }; + // }, + // function(data) { + // $scope.params = data; + // }, + // true + // ); }); diff --git a/html/partials/receive-coins.html b/html/partials/receive-coins.html index 4549a70..5fd7445 100755 --- a/html/partials/receive-coins.html +++ b/html/partials/receive-coins.html @@ -30,25 +30,52 @@
-
-
{{integrated_address}} +
+ {{integarted_address}}
- -
-
{{payment_id8}}
+ +
+ +
- - + + +
+ +
+
+ {{payment_id8_rendered}} +
+
+
+ + + + + + +
+

{{error}}

+
+
+ +
+ -->