wip, valuesforuris
This commit is contained in:
parent
137a270488
commit
b3e9240aa8
4 changed files with 31 additions and 24 deletions
|
@ -965,10 +965,9 @@ class Daemon(AuthJSONRPCServer):
|
|||
(float) amount of lbry credits in wallet
|
||||
"""
|
||||
if address is None:
|
||||
return self._render_response(float(self.wallet.get_balance()))
|
||||
return self.wallet.default_account.get_balance()
|
||||
else:
|
||||
return self._render_response(float(
|
||||
self.wallet.get_address_balance(address, include_unconfirmed)))
|
||||
return self.wallet.get_address_balance(address, include_unconfirmed)
|
||||
|
||||
@requires(WALLET_COMPONENT)
|
||||
@defer.inlineCallbacks
|
||||
|
|
|
@ -96,8 +96,8 @@ class MainNetLedger(BaseLedger):
|
|||
secret_prefix = int2byte(0x1c)
|
||||
pubkey_address_prefix = int2byte(0x55)
|
||||
script_address_prefix = int2byte(0x7a)
|
||||
extended_public_key_prefix = unhexlify('019c354f')
|
||||
extended_private_key_prefix = unhexlify('019c3118')
|
||||
extended_public_key_prefix = unhexlify('0488b21e')
|
||||
extended_private_key_prefix = unhexlify('0488ade4')
|
||||
|
||||
max_target = 0x0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
genesis_hash = '9c89283ba0f3227f6c03b70216b9f665f0118d5e0fa729cedf4fb34d6a34f463'
|
||||
|
@ -126,7 +126,9 @@ class MainNetLedger(BaseLedger):
|
|||
return fee
|
||||
|
||||
def resolve(self, *uris):
|
||||
return self.network.get_values_for_uris(*uris)
|
||||
return self.network.get_values_for_uris(
|
||||
self.headers.hash(), *uris
|
||||
)
|
||||
|
||||
|
||||
class TestNetLedger(MainNetLedger):
|
||||
|
|
|
@ -6,7 +6,8 @@ from torba.constants import COIN
|
|||
from torba.coinselection import CoinSelector
|
||||
from torba.manager import WalletManager as BaseWalletManager
|
||||
|
||||
from lbrynet.wallet.database import WalletDatabase
|
||||
|
||||
from .ledger import MainNetLedger
|
||||
|
||||
|
||||
class BackwardsCompatibleNetwork:
|
||||
|
@ -44,19 +45,24 @@ class LbryWalletManager(BaseWalletManager):
|
|||
|
||||
@classmethod
|
||||
def from_old_config(cls, settings):
|
||||
coin_id = 'lbc_{}'.format(settings['blockchain_name'][-7:])
|
||||
wallet_manager = cls.from_config({
|
||||
'ledgers': {coin_id: {
|
||||
'default_servers': settings['lbryum_servers'],
|
||||
'wallet_path': settings['lbryum_wallet_dir']
|
||||
}}
|
||||
|
||||
ledger_id = {
|
||||
'lbrycrd_main': 'lbc_mainnet',
|
||||
'lbrycrd_testnet': 'lbc_testnet',
|
||||
'lbrycrd_regtest': 'lbc_regtest'
|
||||
}[settings['blockchain_name']]
|
||||
|
||||
ledger_config = {
|
||||
'auto_connect': True,
|
||||
'default_servers': settings['lbryum_servers'],
|
||||
'wallet_path': settings['lbryum_wallet_dir'],
|
||||
'use_keyring': settings['use_keyring']
|
||||
}
|
||||
|
||||
return cls.from_config({
|
||||
'ledgers': {ledger_id: ledger_config},
|
||||
'wallets': [os.path.join(settings['lbryum_wallet_dir'], 'default_wallet')]
|
||||
})
|
||||
ledger = wallet_manager.ledgers.values()[0]
|
||||
wallet_manager.create_wallet(
|
||||
os.path.join(settings['lbryum_wallet_dir'], 'default_torba_wallet'),
|
||||
ledger.coin_class
|
||||
)
|
||||
return wallet_manager
|
||||
|
||||
def get_best_blockhash(self):
|
||||
return defer.succeed('')
|
||||
|
@ -81,9 +87,9 @@ class LbryWalletManager(BaseWalletManager):
|
|||
def get_info_exchanger(self):
|
||||
return LBRYcrdAddressRequester(self)
|
||||
|
||||
def resolve(self, *uris):
|
||||
ledger = self.default_account.coin.ledger # type: LBCLedger
|
||||
return ledger.resolve(uris)
|
||||
def resolve(self, *uris, **kwargs):
|
||||
ledger = self.default_account.ledger # type: MainNetLedger
|
||||
return ledger.resolve(*uris)
|
||||
|
||||
def get_name_claims(self):
|
||||
return defer.succeed([])
|
||||
|
|
|
@ -3,5 +3,5 @@ from torba.basenetwork import BaseNetwork
|
|||
|
||||
class Network(BaseNetwork):
|
||||
|
||||
def get_values_for_uris(self, block_hash, uris):
|
||||
return self.rpc('blockchain.claimtrie.getvaluesforuris', block_hash, uris)
|
||||
def get_values_for_uris(self, block_hash, *uris):
|
||||
return self.rpc('blockchain.claimtrie.getvaluesforuris', block_hash, *uris)
|
||||
|
|
Loading…
Reference in a new issue