Merge branch 'add-channel-import-and-export'

This commit is contained in:
Jack Robison 2017-11-22 14:03:45 -05:00
commit d0581f2cf7
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF
3 changed files with 77 additions and 9 deletions

View file

@ -18,16 +18,17 @@ at anytime.
* *
### Deprecated ### Deprecated
* * `channel_list_mine`, replaced with `channel_list`
* *
### Changed ### Changed
* Check claim schema in `publish` before trying to make the claim, return better error messages * Check claim schema in `publish` before trying to make the claim, return better error messages
* * Renamed `channel_list_mine` to `channel_list`
* Changed `channel_list` to include channels where the certificate info has been imported but the claim is not in the wallet
### Added ### Added
* * Added `channel_import` and `channel_export` commands
* * Added `is_mine` field to `channel_list` results
### Removed ### Removed
* *

View file

@ -904,7 +904,7 @@ class Wallet(object):
@defer.inlineCallbacks @defer.inlineCallbacks
def channel_list(self): def channel_list(self):
certificates = yield self._get_certificate_claims() certificates = yield self.get_certificates_for_signing()
results = [] results = []
for claim in certificates: for claim in certificates:
formatted = yield self._handle_claim_result(claim) formatted = yield self._handle_claim_result(claim)
@ -1135,6 +1135,15 @@ class Wallet(object):
def send_claim_to_address(self, claim_id, destination, amount): def send_claim_to_address(self, claim_id, destination, amount):
return defer.fail(NotImplementedError()) return defer.fail(NotImplementedError())
def import_certificate_info(self, serialized_certificate_info):
return defer.fail(NotImplementedError())
def export_certificate_info(self, certificate_claim_id):
return defer.fail(NotImplementedError())
def get_certificates_for_signing(self):
return defer.fail(NotImplementedError())
def _start(self): def _start(self):
pass pass
@ -1494,6 +1503,15 @@ class LBRYumWallet(Wallet):
def send_claim_to_address(self, claim_id, destination, amount): def send_claim_to_address(self, claim_id, destination, amount):
return self._run_cmd_as_defer_succeed('sendclaimtoaddress', claim_id, destination, amount) return self._run_cmd_as_defer_succeed('sendclaimtoaddress', claim_id, destination, amount)
def import_certificate_info(self, serialized_certificate_info):
return self._run_cmd_as_defer_succeed('importcertificateinfo', serialized_certificate_info)
def export_certificate_info(self, certificate_claim_id):
return self._run_cmd_as_defer_succeed('exportcertificateinfo', certificate_claim_id)
def get_certificates_for_signing(self):
return self._run_cmd_as_defer_succeed('getcertificatesforsigning')
# TODO: get rid of this function. lbryum should take care of it # TODO: get rid of this function. lbryum should take care of it
def _save_wallet(self, val=None): def _save_wallet(self, val=None):
self.wallet.storage.write() self.wallet.storage.write()

View file

@ -1742,9 +1742,27 @@ class Daemon(AuthJSONRPCServer):
@AuthJSONRPCServer.auth_required @AuthJSONRPCServer.auth_required
@defer.inlineCallbacks @defer.inlineCallbacks
def jsonrpc_channel_list(self):
"""
Get certificate claim infos for channels that can be published to
Usage:
channel_list
Returns:
(list) ClaimDict, includes 'is_mine' field to indicate if the certificate claim
is in the wallet.
"""
result = yield self.session.wallet.channel_list()
response = yield self._render_response(result)
defer.returnValue(response)
@AuthJSONRPCServer.deprecated("channel_list")
@AuthJSONRPCServer.auth_required
def jsonrpc_channel_list_mine(self): def jsonrpc_channel_list_mine(self):
""" """
Get my channels Get certificate claim infos for channels that can be published to (deprecated)
Usage: Usage:
channel_list_mine channel_list_mine
@ -1753,9 +1771,40 @@ class Daemon(AuthJSONRPCServer):
(list) ClaimDict (list) ClaimDict
""" """
result = yield self.session.wallet.channel_list() return self.jsonrpc_channel_list()
response = yield self._render_response(result)
defer.returnValue(response) @AuthJSONRPCServer.auth_required
@defer.inlineCallbacks
def jsonrpc_channel_export(self, claim_id):
"""
Export serialized channel signing information for a given certificate claim id
Usage:
channel_export (<claim_id> | --claim_id=<claim_id>)
Returns:
(str) Serialized certificate information
"""
result = yield self.session.wallet.export_certificate_info(claim_id)
defer.returnValue(result)
@AuthJSONRPCServer.auth_required
@defer.inlineCallbacks
def jsonrpc_channel_import(self, serialized_certificate_info):
"""
Import serialized channel signing information (to allow signing new claims to the channel)
Usage:
channel_import (<serialized_certificate_info> |
--serialized_certificate_info=<serialized_certificate_info>)
Returns:
(dict) Result dictionary
"""
result = yield self.session.wallet.import_certificate_info(serialized_certificate_info)
defer.returnValue(result)
@AuthJSONRPCServer.auth_required @AuthJSONRPCServer.auth_required
@defer.inlineCallbacks @defer.inlineCallbacks