diff --git a/ui/js/lbry.js b/ui/js/lbry.js index aeb91e12f..2105abfb4 100644 --- a/ui/js/lbry.js +++ b/ui/js/lbry.js @@ -155,7 +155,11 @@ lbry.checkFirstRun = function(callback) { } lbry.getNewAddress = function(callback) { - lbry.call('get_new_address', {}, callback); + lbry.call('wallet_new_address', {}, callback); +} + +lbry.getUnusedAddress = function(callback) { + lbry.call('wallet_unused_address', {}, callback); } lbry.checkAddressIsMine = function(address, callback) { @@ -177,17 +181,18 @@ lbry.setDaemonSetting = function(setting, value, callback) { } -lbry.getBalance = function(callback) -{ - lbry.call("get_balance", {}, callback); +lbry.getBalance = function(callback) { + lbry.call("wallet_balance", {}, callback); } -lbry.sendToAddress = function(amount, address, callback, errorCallback) -{ +lbry.sendToAddress = function(amount, address, callback, errorCallback) { lbry.call("send_amount_to_address", { "amount" : amount, "address": address }, callback, errorCallback); } lbry.resolveName = function(name, callback) { + if (!name) { + throw new Error(`Name required.`); + } lbry.call('resolve_name', { 'name': name }, callback, () => { // For now, assume any error means the name was not resolved callback(null); @@ -195,10 +200,16 @@ lbry.resolveName = function(name, callback) { } lbry.getStream = function(name, callback) { + if (!name) { + throw new Error(`Name required.`); + } lbry.call('get', { 'name': name }, callback); }; lbry.getClaimInfo = function(name, callback) { + if (!name) { + throw new Error(`Name required.`); + } lbry.call('get_claim_info', { name: name }, callback); } @@ -209,10 +220,16 @@ lbry.getMyClaim = function(name, callback) { } lbry.getKeyFee = function(name, callback, errorCallback) { + if (!name) { + throw new Error(`Name required.`); + } lbry.call('stream_cost_estimate', { name: name }, callback, errorCallback); } lbry.getTotalCost = function(name, size, callback, errorCallback) { + if (!name) { + throw new Error(`Name required.`); + } lbry.call('stream_cost_estimate', { name: name, size: size, @@ -235,6 +252,9 @@ lbry.getPeersForBlobHash = function(blobHash, callback) { } lbry.getStreamAvailability = function(name, callback, errorCallback) { + if (!name) { + throw new Error(`Name required.`); + } lbry.call('get_availability', {name: name}, callback, errorCallback); } @@ -249,6 +269,10 @@ lbry.getCostInfoForName = function(name, callback, errorCallback) { * - includes_data: Boolean; indicates whether or not the data fee info * from Lighthouse is included. */ + if (!name) { + throw new Error(`Name required.`); + } + function getCostWithData(name, size, callback, errorCallback) { lbry.getTotalCost(name, size, (cost) => { callback({ diff --git a/ui/js/page/claim_code.js b/ui/js/page/claim_code.js index dcdb03cf9..7a9976824 100644 --- a/ui/js/page/claim_code.js +++ b/ui/js/page/claim_code.js @@ -46,7 +46,7 @@ var ClaimCodePage = React.createClass({ submitting: true, }); - lbry.getNewAddress((address) => { + lbry.getUnusedAddress((address) => { var code = this.refs.code.value; var email = this.refs.email.value; diff --git a/ui/js/page/publish.js b/ui/js/page/publish.js index be612b314..019783587 100644 --- a/ui/js/page/publish.js +++ b/ui/js/page/publish.js @@ -92,7 +92,7 @@ var PublishPage = React.createClass({ }; if (this.state.isFee) { - lbry.getNewAddress((address) => { + lbry.getUnusedAddress((address) => { metadata.fee = {}; metadata.fee[this.state.feeCurrency] = { amount: parseFloat(this.state.feeAmount), diff --git a/ui/js/page/referral.js b/ui/js/page/referral.js index 29f273593..1f98e49ff 100644 --- a/ui/js/page/referral.js +++ b/ui/js/page/referral.js @@ -43,7 +43,7 @@ var ReferralPage = React.createClass({ submitting: true, }); - lbry.getNewAddress((address) => { + lbry.getUnusedAddress((address) => { var code = this.refs.code.value; var email = this.refs.email.value; diff --git a/ui/js/page/wallet.js b/ui/js/page/wallet.js index 72e683ad0..2ace64c27 100644 --- a/ui/js/page/wallet.js +++ b/ui/js/page/wallet.js @@ -14,6 +14,19 @@ var AddressSection = React.createClass({ event.preventDefault(); } + lbry.getUnusedAddress((address) => { + window.localStorage.setItem('wallet_address', address); + this.setState({ + address: address, + }); + }); + }, + + _getNewAddress: function(event) { + if (typeof event !== 'undefined') { + event.preventDefault(); + } + lbry.getNewAddress((address) => { window.localStorage.setItem('wallet_address', address); this.setState({ @@ -21,6 +34,7 @@ var AddressSection = React.createClass({ }); }); }, + getInitialState: function() { return { address: null, @@ -47,7 +61,7 @@ var AddressSection = React.createClass({ return (

Wallet Address

-
+

Other LBRY users may send credits to you by entering this address on the "Send" page.