fix publish output

This commit is contained in:
Kay Kurokawa 2017-01-06 12:17:49 -05:00
parent 3c60b35e2e
commit 9e7b69f4a0
3 changed files with 29 additions and 8 deletions

View file

@ -609,7 +609,21 @@ class Wallet(object):
meta_for_return[k] = new_metadata[k] meta_for_return[k] = new_metadata[k]
return defer.succeed(Metadata(meta_for_return)) return defer.succeed(Metadata(meta_for_return))
"""
Claim a name, update if name already claimed by user
@param name: name to claim
@param bid: bid amount
@param m: metadata
@return: Deferred which returns a dict containing below items
txid - txid of the resulting transaction
nout - nout of the resulting claim
fee - transaction fee paid to make claim
claim_id - claim id of the claim
"""
def claim_name(self, name, bid, m): def claim_name(self, name, bid, m):
def _save_metadata(claim_out, metadata): def _save_metadata(claim_out, metadata):
if not claim_out['success']: if not claim_out['success']:
@ -635,6 +649,7 @@ class Wallet(object):
lambda new_metadata: self._send_name_claim_update(name, claim['claim_id'], lambda new_metadata: self._send_name_claim_update(name, claim['claim_id'],
claim_outpoint, claim_outpoint,
new_metadata, _bid)) new_metadata, _bid))
d.addCallback(lambda claim_out: claim_out.update({'claim_id':claim['claim_id']}))
return d return d
meta = Metadata(m) meta = Metadata(m)

View file

@ -1686,7 +1686,7 @@ class Daemon(AuthJSONRPCServer):
'txid' : txid of resulting transaction if succesful 'txid' : txid of resulting transaction if succesful
'nout' : nout of the resulting support claim if succesful 'nout' : nout of the resulting support claim if succesful
'fee' : fee paid for the claim transaction if succesful 'fee' : fee paid for the claim transaction if succesful
'claimid' : claimid of the resulting transaction 'claim_id' : claimid of the resulting transaction
""" """
def _set_address(address, currency, m): def _set_address(address, currency, m):

View file

@ -30,6 +30,8 @@ class Publisher(object):
self.lbry_file = None self.lbry_file = None
self.txid = None self.txid = None
self.nout = None self.nout = None
self.claim_id = None
self.fee = None
self.stream_hash = None self.stream_hash = None
# TODO: this needs to be passed into the constructor # TODO: this needs to be passed into the constructor
reflector_server = random.choice(conf.settings.reflector_servers) reflector_server = random.choice(conf.settings.reflector_servers)
@ -44,6 +46,8 @@ class Publisher(object):
out = {} out = {}
out['nout'] = self.nout out['nout'] = self.nout
out['txid'] = self.txid out['txid'] = self.txid
out['claim_id'] = self.claim_id
out['fee'] = self.fee
return defer.succeed(out) return defer.succeed(out)
self.publish_name = name self.publish_name = name
@ -136,15 +140,17 @@ class Publisher(object):
self._update_metadata() self._update_metadata()
m = Metadata(self.metadata) m = Metadata(self.metadata)
def set_txid_nout(claim_out): def set_claim_out(claim_out):
txid = claim_out['txid'] log.debug('Name claimed using txid: %s, nout: %d, claim_id: %s, fee :%f',
nout = claim_out['nout'] claim_out['txid'], claim_out['nout'],
log.debug('Name claimed using txid: %s, nout: %d', txid, nout) claim_out['claim_id'], claim_out['fee'])
self.txid = txid self.txid = claim_out['txid']
self.nout = nout self.nout = claim_out['nout']
self.claim_id = claim_out['claim_id']
self.fee = claim_out['fee']
d = self.wallet.claim_name(self.publish_name, self.bid_amount, m) d = self.wallet.claim_name(self.publish_name, self.bid_amount, m)
d.addCallback(set_txid_nout) d.addCallback(set_claim_out)
return d return d
def _update_metadata(self): def _update_metadata(self):