add change_address param to publish

This commit is contained in:
Jack Robison 2017-06-12 13:32:01 -04:00
parent 00fbe306c5
commit 9c88f820f9
7 changed files with 34 additions and 25 deletions

View file

@ -10,7 +10,7 @@ at anytime.
## [Unreleased]
### Added
* Add `claim_send_to_address`
*
* Add `change_address` argument to `publish`
### Changed
* Support resolution of multiple uris with `resolve`, all results are keyed by uri

View file

@ -898,7 +898,8 @@ class Wallet(object):
defer.returnValue(results)
@defer.inlineCallbacks
def claim_name(self, name, bid, metadata, certificate_id=None, claim_address=None):
def claim_name(self, name, bid, metadata, certificate_id=None, claim_address=None,
change_address=None):
"""
Claim a name, or update if name already claimed by user
@ -907,6 +908,7 @@ class Wallet(object):
@param metadata: ClaimDict compliant dict
@param certificate_id: str (optional), claim id of channel certificate
@param claim_address: str (optional), address to send claim to
@param change_address: str (optional), address to send change
@return: Deferred which returns a dict containing below items
txid - txid of the resulting transaction
@ -922,7 +924,7 @@ class Wallet(object):
raise InsufficientFundsError()
claim = yield self._send_name_claim(name, serialized.encode('hex'),
bid, certificate_id, claim_address)
bid, certificate_id, claim_address, change_address)
if not claim['success']:
msg = 'Claim to name {} failed: {}'.format(name, claim['reason'])
@ -1060,7 +1062,8 @@ class Wallet(object):
def _claim_certificate(self, name, amount):
return defer.fail(NotImplementedError())
def _send_name_claim(self, name, val, amount, certificate_id=None, claim_address=None):
def _send_name_claim(self, name, val, amount, certificate_id=None, claim_address=None,
change_address=None):
return defer.fail(NotImplementedError())
def _abandon_claim(self, claim_id):
@ -1334,11 +1337,12 @@ class LBRYumWallet(Wallet):
@defer.inlineCallbacks
def _send_name_claim(self, name, value, amount,
certificate_id=None, claim_address=None):
certificate_id=None, claim_address=None, change_address=None):
log.info("Send claim: %s for %s: %s ", name, amount, value)
claim_out = yield self._run_cmd_as_defer_succeed('claim', name, value, amount,
certificate_id=certificate_id,
claim_addr=claim_address)
claim_addr=claim_address,
change_addr=change_address)
defer.returnValue(claim_out)
@defer.inlineCallbacks

View file

@ -681,8 +681,8 @@ class Daemon(AuthJSONRPCServer):
defer.returnValue(result)
@defer.inlineCallbacks
def _publish_stream(self, name, bid, claim_dict,
file_path=None, certificate_id=None, claim_address=None):
def _publish_stream(self, name, bid, claim_dict, file_path=None, certificate_id=None,
claim_address=None, change_address=None):
publisher = Publisher(self.session, self.lbry_file_manager, self.session.wallet,
certificate_id)
@ -690,10 +690,11 @@ class Daemon(AuthJSONRPCServer):
if bid <= 0.0:
raise Exception("Invalid bid")
if not file_path:
claim_out = yield publisher.publish_stream(name, bid, claim_dict, claim_address)
claim_out = yield publisher.publish_stream(name, bid, claim_dict, claim_address,
change_address)
else:
claim_out = yield publisher.create_and_publish_stream(name, bid, claim_dict,
file_path, claim_address)
claim_out = yield publisher.create_and_publish_stream(name, bid, claim_dict, file_path,
claim_address, change_address)
if conf.settings['reflect_uploads']:
d = reupload.reflect_stream(publisher.lbry_file)
d.addCallbacks(lambda _: log.info("Reflected new publication to lbry://%s", name),
@ -1686,7 +1687,7 @@ class Daemon(AuthJSONRPCServer):
description=None, author=None, language=None, license=None,
license_url=None, thumbnail=None, preview=None, nsfw=None, sources=None,
channel_name=None, channel_id=None,
claim_address=None):
claim_address=None, change_address=None):
"""
Make a new name claim and publish associated data to lbrynet,
update over existing claim if user already has a claim for name.
@ -1710,7 +1711,7 @@ class Daemon(AuthJSONRPCServer):
[--license=<license>] [--license_url=<license_url>] [--thumbnail=<thumbnail>]
[--preview=<preview>] [--nsfw=<nsfw>] [--sources=<sources>]
[--channel_name=<channel_name>] [--channel_id=<channel_id>]
[--claim_address=<claim_address>]
[--claim_address=<claim_address>] [--change_address=<change_address>]
Options:
--metadata=<metadata> : ClaimDict to associate with the claim.
@ -1825,7 +1826,8 @@ class Daemon(AuthJSONRPCServer):
'name': name,
'file_path': file_path,
'bid': bid,
'claim_address':claim_address,
'claim_address': claim_address,
'change_address': change_address,
'claim_dict': claim_dict,
})
@ -1843,8 +1845,8 @@ class Daemon(AuthJSONRPCServer):
else:
certificate_id = None
result = yield self._publish_stream(name, bid, claim_dict, file_path,
certificate_id, claim_address)
result = yield self._publish_stream(name, bid, claim_dict, file_path, certificate_id,
claim_address, change_address)
response = yield self._render_response(result)
defer.returnValue(response)

View file

@ -21,7 +21,8 @@ class Publisher(object):
self.lbry_file = None
@defer.inlineCallbacks
def create_and_publish_stream(self, name, bid, claim_dict, file_path, claim_address=None):
def create_and_publish_stream(self, name, bid, claim_dict, file_path, claim_address=None,
change_address=None):
"""Create lbry file and make claim"""
log.info('Starting publish for %s', name)
if not os.path.isfile(file_path):
@ -44,23 +45,24 @@ class Publisher(object):
claim_dict['stream']['source']['contentType'] = get_content_type(file_path)
claim_dict['stream']['source']['version'] = "_0_0_1" # need current version here
claim_out = yield self.make_claim(name, bid, claim_dict, claim_address)
claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address)
self.lbry_file.completed = True
yield self.lbry_file.load_file_attributes(sd_hash)
yield self.lbry_file.save_status()
defer.returnValue(claim_out)
@defer.inlineCallbacks
def publish_stream(self, name, bid, claim_dict, claim_address=None):
def publish_stream(self, name, bid, claim_dict, claim_address=None, change_address=None):
"""Make a claim without creating a lbry file"""
claim_out = yield self.make_claim(name, bid, claim_dict, claim_address)
claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address)
defer.returnValue(claim_out)
@defer.inlineCallbacks
def make_claim(self, name, bid, claim_dict, claim_address=None):
def make_claim(self, name, bid, claim_dict, claim_address=None, change_address=None):
claim_out = yield self.wallet.claim_name(name, bid, claim_dict,
certificate_id=self.certificate_id,
claim_address=claim_address)
claim_address=claim_address,
change_address=change_address)
defer.returnValue(claim_out)

View file

@ -14,7 +14,7 @@ jsonrpc==1.2
jsonrpclib==0.1.7
jsonschema==2.5.1
git+https://github.com/lbryio/lbryschema.git@v0.0.7#egg=lbryschema
git+https://github.com/lbryio/lbryum.git@v2.8.0#egg=lbryum
git+https://github.com/lbryio/lbryum.git@v2.8.1#egg=lbryum
miniupnpc==1.9
pbkdf2==1.3
pycrypto==2.6.1

View file

@ -21,7 +21,7 @@ requires = [
'envparse',
'jsonrpc',
'jsonschema',
'lbryum==2.8.0',
'lbryum==2.8.1',
'lbryschema==0.0.7',
'miniupnpc',
'pycrypto',

View file

@ -67,7 +67,8 @@ class WalletTest(unittest.TestCase):
self.assertEqual(expected_claim_out['nout'], claim_out['nout'])
self.assertEqual(expected_claim_out['txid'], claim_out['txid'])
def success_send_name_claim(self, name, val, amount, certificate_id=None, claim_address=None):
def success_send_name_claim(self, name, val, amount, certificate_id=None,
claim_address=None, change_address=None):
return expected_claim_out
MocLbryumWallet._send_name_claim = success_send_name_claim