forked from LBRYCommunity/lbry-sdk
add change_address param to publish
This commit is contained in:
parent
00fbe306c5
commit
9c88f820f9
7 changed files with 34 additions and 25 deletions
|
@ -10,7 +10,7 @@ at anytime.
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
* Add `claim_send_to_address`
|
* Add `claim_send_to_address`
|
||||||
*
|
* Add `change_address` argument to `publish`
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Support resolution of multiple uris with `resolve`, all results are keyed by uri
|
* Support resolution of multiple uris with `resolve`, all results are keyed by uri
|
||||||
|
|
|
@ -898,7 +898,8 @@ class Wallet(object):
|
||||||
defer.returnValue(results)
|
defer.returnValue(results)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@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
|
Claim a name, or update if name already claimed by user
|
||||||
|
|
||||||
|
@ -907,6 +908,7 @@ class Wallet(object):
|
||||||
@param metadata: ClaimDict compliant dict
|
@param metadata: ClaimDict compliant dict
|
||||||
@param certificate_id: str (optional), claim id of channel certificate
|
@param certificate_id: str (optional), claim id of channel certificate
|
||||||
@param claim_address: str (optional), address to send claim to
|
@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
|
@return: Deferred which returns a dict containing below items
|
||||||
txid - txid of the resulting transaction
|
txid - txid of the resulting transaction
|
||||||
|
@ -922,7 +924,7 @@ class Wallet(object):
|
||||||
raise InsufficientFundsError()
|
raise InsufficientFundsError()
|
||||||
|
|
||||||
claim = yield self._send_name_claim(name, serialized.encode('hex'),
|
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']:
|
if not claim['success']:
|
||||||
msg = 'Claim to name {} failed: {}'.format(name, claim['reason'])
|
msg = 'Claim to name {} failed: {}'.format(name, claim['reason'])
|
||||||
|
@ -1060,7 +1062,8 @@ class Wallet(object):
|
||||||
def _claim_certificate(self, name, amount):
|
def _claim_certificate(self, name, amount):
|
||||||
return defer.fail(NotImplementedError())
|
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())
|
return defer.fail(NotImplementedError())
|
||||||
|
|
||||||
def _abandon_claim(self, claim_id):
|
def _abandon_claim(self, claim_id):
|
||||||
|
@ -1334,11 +1337,12 @@ class LBRYumWallet(Wallet):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _send_name_claim(self, name, value, amount,
|
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)
|
log.info("Send claim: %s for %s: %s ", name, amount, value)
|
||||||
claim_out = yield self._run_cmd_as_defer_succeed('claim', name, value, amount,
|
claim_out = yield self._run_cmd_as_defer_succeed('claim', name, value, amount,
|
||||||
certificate_id=certificate_id,
|
certificate_id=certificate_id,
|
||||||
claim_addr=claim_address)
|
claim_addr=claim_address,
|
||||||
|
change_addr=change_address)
|
||||||
defer.returnValue(claim_out)
|
defer.returnValue(claim_out)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -681,8 +681,8 @@ class Daemon(AuthJSONRPCServer):
|
||||||
defer.returnValue(result)
|
defer.returnValue(result)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _publish_stream(self, name, bid, claim_dict,
|
def _publish_stream(self, name, bid, claim_dict, file_path=None, certificate_id=None,
|
||||||
file_path=None, certificate_id=None, claim_address=None):
|
claim_address=None, change_address=None):
|
||||||
|
|
||||||
publisher = Publisher(self.session, self.lbry_file_manager, self.session.wallet,
|
publisher = Publisher(self.session, self.lbry_file_manager, self.session.wallet,
|
||||||
certificate_id)
|
certificate_id)
|
||||||
|
@ -690,10 +690,11 @@ class Daemon(AuthJSONRPCServer):
|
||||||
if bid <= 0.0:
|
if bid <= 0.0:
|
||||||
raise Exception("Invalid bid")
|
raise Exception("Invalid bid")
|
||||||
if not file_path:
|
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:
|
else:
|
||||||
claim_out = yield publisher.create_and_publish_stream(name, bid, claim_dict,
|
claim_out = yield publisher.create_and_publish_stream(name, bid, claim_dict, file_path,
|
||||||
file_path, claim_address)
|
claim_address, change_address)
|
||||||
if conf.settings['reflect_uploads']:
|
if conf.settings['reflect_uploads']:
|
||||||
d = reupload.reflect_stream(publisher.lbry_file)
|
d = reupload.reflect_stream(publisher.lbry_file)
|
||||||
d.addCallbacks(lambda _: log.info("Reflected new publication to lbry://%s", name),
|
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,
|
description=None, author=None, language=None, license=None,
|
||||||
license_url=None, thumbnail=None, preview=None, nsfw=None, sources=None,
|
license_url=None, thumbnail=None, preview=None, nsfw=None, sources=None,
|
||||||
channel_name=None, channel_id=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,
|
Make a new name claim and publish associated data to lbrynet,
|
||||||
update over existing claim if user already has a claim for name.
|
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>]
|
[--license=<license>] [--license_url=<license_url>] [--thumbnail=<thumbnail>]
|
||||||
[--preview=<preview>] [--nsfw=<nsfw>] [--sources=<sources>]
|
[--preview=<preview>] [--nsfw=<nsfw>] [--sources=<sources>]
|
||||||
[--channel_name=<channel_name>] [--channel_id=<channel_id>]
|
[--channel_name=<channel_name>] [--channel_id=<channel_id>]
|
||||||
[--claim_address=<claim_address>]
|
[--claim_address=<claim_address>] [--change_address=<change_address>]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--metadata=<metadata> : ClaimDict to associate with the claim.
|
--metadata=<metadata> : ClaimDict to associate with the claim.
|
||||||
|
@ -1825,7 +1826,8 @@ class Daemon(AuthJSONRPCServer):
|
||||||
'name': name,
|
'name': name,
|
||||||
'file_path': file_path,
|
'file_path': file_path,
|
||||||
'bid': bid,
|
'bid': bid,
|
||||||
'claim_address':claim_address,
|
'claim_address': claim_address,
|
||||||
|
'change_address': change_address,
|
||||||
'claim_dict': claim_dict,
|
'claim_dict': claim_dict,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1843,8 +1845,8 @@ class Daemon(AuthJSONRPCServer):
|
||||||
else:
|
else:
|
||||||
certificate_id = None
|
certificate_id = None
|
||||||
|
|
||||||
result = yield self._publish_stream(name, bid, claim_dict, file_path,
|
result = yield self._publish_stream(name, bid, claim_dict, file_path, certificate_id,
|
||||||
certificate_id, claim_address)
|
claim_address, change_address)
|
||||||
response = yield self._render_response(result)
|
response = yield self._render_response(result)
|
||||||
defer.returnValue(response)
|
defer.returnValue(response)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ class Publisher(object):
|
||||||
self.lbry_file = None
|
self.lbry_file = None
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@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"""
|
"""Create lbry file and make claim"""
|
||||||
log.info('Starting publish for %s', name)
|
log.info('Starting publish for %s', name)
|
||||||
if not os.path.isfile(file_path):
|
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']['contentType'] = get_content_type(file_path)
|
||||||
claim_dict['stream']['source']['version'] = "_0_0_1" # need current version here
|
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
|
self.lbry_file.completed = True
|
||||||
yield self.lbry_file.load_file_attributes(sd_hash)
|
yield self.lbry_file.load_file_attributes(sd_hash)
|
||||||
yield self.lbry_file.save_status()
|
yield self.lbry_file.save_status()
|
||||||
defer.returnValue(claim_out)
|
defer.returnValue(claim_out)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@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"""
|
"""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.returnValue(claim_out)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@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,
|
claim_out = yield self.wallet.claim_name(name, bid, claim_dict,
|
||||||
certificate_id=self.certificate_id,
|
certificate_id=self.certificate_id,
|
||||||
claim_address=claim_address)
|
claim_address=claim_address,
|
||||||
|
change_address=change_address)
|
||||||
defer.returnValue(claim_out)
|
defer.returnValue(claim_out)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ jsonrpc==1.2
|
||||||
jsonrpclib==0.1.7
|
jsonrpclib==0.1.7
|
||||||
jsonschema==2.5.1
|
jsonschema==2.5.1
|
||||||
git+https://github.com/lbryio/lbryschema.git@v0.0.7#egg=lbryschema
|
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
|
miniupnpc==1.9
|
||||||
pbkdf2==1.3
|
pbkdf2==1.3
|
||||||
pycrypto==2.6.1
|
pycrypto==2.6.1
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -21,7 +21,7 @@ requires = [
|
||||||
'envparse',
|
'envparse',
|
||||||
'jsonrpc',
|
'jsonrpc',
|
||||||
'jsonschema',
|
'jsonschema',
|
||||||
'lbryum==2.8.0',
|
'lbryum==2.8.1',
|
||||||
'lbryschema==0.0.7',
|
'lbryschema==0.0.7',
|
||||||
'miniupnpc',
|
'miniupnpc',
|
||||||
'pycrypto',
|
'pycrypto',
|
||||||
|
|
|
@ -67,7 +67,8 @@ class WalletTest(unittest.TestCase):
|
||||||
self.assertEqual(expected_claim_out['nout'], claim_out['nout'])
|
self.assertEqual(expected_claim_out['nout'], claim_out['nout'])
|
||||||
self.assertEqual(expected_claim_out['txid'], claim_out['txid'])
|
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
|
return expected_claim_out
|
||||||
|
|
||||||
MocLbryumWallet._send_name_claim = success_send_name_claim
|
MocLbryumWallet._send_name_claim = success_send_name_claim
|
||||||
|
|
Loading…
Reference in a new issue