switch to get_unused_address whe loading wallet page

This commit is contained in:
Alex Grintsvayg 2017-04-10 13:44:54 -04:00
parent bb6a297606
commit 5ce9319b07
5 changed files with 48 additions and 10 deletions

View file

@ -155,7 +155,11 @@ lbry.checkFirstRun = function(callback) {
} }
lbry.getNewAddress = 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) { lbry.checkAddressIsMine = function(address, callback) {
@ -177,17 +181,18 @@ lbry.setDaemonSetting = function(setting, value, callback) {
} }
lbry.getBalance = function(callback) lbry.getBalance = function(callback) {
{ lbry.call("wallet_balance", {}, callback);
lbry.call("get_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.call("send_amount_to_address", { "amount" : amount, "address": address }, callback, errorCallback);
} }
lbry.resolveName = function(name, callback) { lbry.resolveName = function(name, callback) {
if (!name) {
throw new Error(`Name required.`);
}
lbry.call('resolve_name', { 'name': name }, callback, () => { lbry.call('resolve_name', { 'name': name }, callback, () => {
// For now, assume any error means the name was not resolved // For now, assume any error means the name was not resolved
callback(null); callback(null);
@ -195,10 +200,16 @@ lbry.resolveName = function(name, callback) {
} }
lbry.getStream = function(name, callback) { lbry.getStream = function(name, callback) {
if (!name) {
throw new Error(`Name required.`);
}
lbry.call('get', { 'name': name }, callback); lbry.call('get', { 'name': name }, callback);
}; };
lbry.getClaimInfo = function(name, callback) { lbry.getClaimInfo = function(name, callback) {
if (!name) {
throw new Error(`Name required.`);
}
lbry.call('get_claim_info', { name: name }, callback); lbry.call('get_claim_info', { name: name }, callback);
} }
@ -209,10 +220,16 @@ lbry.getMyClaim = function(name, callback) {
} }
lbry.getKeyFee = function(name, callback, errorCallback) { lbry.getKeyFee = function(name, callback, errorCallback) {
if (!name) {
throw new Error(`Name required.`);
}
lbry.call('stream_cost_estimate', { name: name }, callback, errorCallback); lbry.call('stream_cost_estimate', { name: name }, callback, errorCallback);
} }
lbry.getTotalCost = function(name, size, callback, errorCallback) { lbry.getTotalCost = function(name, size, callback, errorCallback) {
if (!name) {
throw new Error(`Name required.`);
}
lbry.call('stream_cost_estimate', { lbry.call('stream_cost_estimate', {
name: name, name: name,
size: size, size: size,
@ -235,6 +252,9 @@ lbry.getPeersForBlobHash = function(blobHash, callback) {
} }
lbry.getStreamAvailability = function(name, callback, errorCallback) { lbry.getStreamAvailability = function(name, callback, errorCallback) {
if (!name) {
throw new Error(`Name required.`);
}
lbry.call('get_availability', {name: name}, callback, errorCallback); 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 * - includes_data: Boolean; indicates whether or not the data fee info
* from Lighthouse is included. * from Lighthouse is included.
*/ */
if (!name) {
throw new Error(`Name required.`);
}
function getCostWithData(name, size, callback, errorCallback) { function getCostWithData(name, size, callback, errorCallback) {
lbry.getTotalCost(name, size, (cost) => { lbry.getTotalCost(name, size, (cost) => {
callback({ callback({

View file

@ -46,7 +46,7 @@ var ClaimCodePage = React.createClass({
submitting: true, submitting: true,
}); });
lbry.getNewAddress((address) => { lbry.getUnusedAddress((address) => {
var code = this.refs.code.value; var code = this.refs.code.value;
var email = this.refs.email.value; var email = this.refs.email.value;

View file

@ -92,7 +92,7 @@ var PublishPage = React.createClass({
}; };
if (this.state.isFee) { if (this.state.isFee) {
lbry.getNewAddress((address) => { lbry.getUnusedAddress((address) => {
metadata.fee = {}; metadata.fee = {};
metadata.fee[this.state.feeCurrency] = { metadata.fee[this.state.feeCurrency] = {
amount: parseFloat(this.state.feeAmount), amount: parseFloat(this.state.feeAmount),

View file

@ -43,7 +43,7 @@ var ReferralPage = React.createClass({
submitting: true, submitting: true,
}); });
lbry.getNewAddress((address) => { lbry.getUnusedAddress((address) => {
var code = this.refs.code.value; var code = this.refs.code.value;
var email = this.refs.email.value; var email = this.refs.email.value;

View file

@ -14,6 +14,19 @@ var AddressSection = React.createClass({
event.preventDefault(); 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) => { lbry.getNewAddress((address) => {
window.localStorage.setItem('wallet_address', address); window.localStorage.setItem('wallet_address', address);
this.setState({ this.setState({
@ -21,6 +34,7 @@ var AddressSection = React.createClass({
}); });
}); });
}, },
getInitialState: function() { getInitialState: function() {
return { return {
address: null, address: null,
@ -47,7 +61,7 @@ var AddressSection = React.createClass({
return ( return (
<section className="card"> <section className="card">
<h3>Wallet Address</h3> <h3>Wallet Address</h3>
<Address address={this.state.address} /> <Link text="Get new address" icon='icon-refresh' onClick={this._refreshAddress} style={addressRefreshButtonStyle} /> <Address address={this.state.address} /> <Link text="Get new address" icon='icon-refresh' onClick={this._getNewAddress} style={addressRefreshButtonStyle} />
<input type='submit' className='hidden' /> <input type='submit' className='hidden' />
<div className="help"> <div className="help">
<p>Other LBRY users may send credits to you by entering this address on the "Send" page.</p> <p>Other LBRY users may send credits to you by entering this address on the "Send" page.</p>