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.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({

View file

@ -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;

View file

@ -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),

View file

@ -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;

View file

@ -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 (
<section className="card">
<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' />
<div className="help">
<p>Other LBRY users may send credits to you by entering this address on the "Send" page.</p>