forked from LBRYCommunity/lbry-sdk
Merge branch 'master' into blob-prices
This commit is contained in:
commit
b671a3c2ba
7 changed files with 72 additions and 26 deletions
|
@ -135,7 +135,7 @@ test_script:
|
||||||
|
|
||||||
C:\Python27\Scripts\pip.exe install pylint
|
C:\Python27\Scripts\pip.exe install pylint
|
||||||
|
|
||||||
C:\Python27\python.exe C:\Python27\Scripts\trial.py C:\projects\lbry\tests
|
C:\Python27\python.exe C:\Python27\Scripts\trial.py C:\projects\lbry\tests\unit
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: dist/*.msi
|
- path: dist/*.msi
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.4.9
|
current_version = 0.5.0
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__version__ = "0.4.9"
|
__version__ = "0.5.0"
|
||||||
version = tuple(__version__.split('.'))
|
version = tuple(__version__.split('.'))
|
||||||
|
|
||||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
|
@ -368,6 +368,31 @@ class LBRYWallet(object):
|
||||||
d.addCallback(_get_id_for_return)
|
d.addCallback(_get_id_for_return)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def get_my_claim(self, name):
|
||||||
|
def _convert_units(claim):
|
||||||
|
amount = Decimal(claim['nEffectiveAmount'] / COIN)
|
||||||
|
claim['nEffectiveAmount'] = amount
|
||||||
|
return claim
|
||||||
|
|
||||||
|
def _get_claim_for_return(claim):
|
||||||
|
if not claim:
|
||||||
|
return False
|
||||||
|
d = self.get_claim(name, claim['claim_id'])
|
||||||
|
d.addCallback(_convert_units)
|
||||||
|
d.addCallback(lambda clm: self._format_claim_for_return(name, clm, claim['txid']))
|
||||||
|
return d
|
||||||
|
|
||||||
|
def _get_my_unspent_claim(claims):
|
||||||
|
for claim in claims:
|
||||||
|
if claim['name'] == name and not claim['is spent']:
|
||||||
|
return claim
|
||||||
|
return False
|
||||||
|
|
||||||
|
d = self.get_name_claims()
|
||||||
|
d.addCallback(_get_my_unspent_claim)
|
||||||
|
d.addCallback(_get_claim_for_return)
|
||||||
|
return d
|
||||||
|
|
||||||
def get_claim_info(self, name, txid=None):
|
def get_claim_info(self, name, txid=None):
|
||||||
if not txid:
|
if not txid:
|
||||||
d = self._get_value_for_name(name)
|
d = self._get_value_for_name(name)
|
||||||
|
@ -377,9 +402,20 @@ class LBRYWallet(object):
|
||||||
d.addErrback(lambda _: False)
|
d.addErrback(lambda _: False)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def _format_claim_for_return(self, name, claim, txid, metadata=None, meta_version=None):
|
||||||
|
result = {}
|
||||||
|
result['claim_id'] = claim['claimId']
|
||||||
|
result['amount'] = claim['nEffectiveAmount']
|
||||||
|
result['height'] = claim['nHeight']
|
||||||
|
result['name'] = name
|
||||||
|
result['txid'] = txid
|
||||||
|
result['value'] = metadata if metadata else json.loads(claim['value'])
|
||||||
|
result['supports'] = [{'txid': support['txid'], 'n': support['n']} for support in claim['supports']]
|
||||||
|
result['meta_version'] = meta_version if meta_version else result['value'].get('ver', '0.0.1')
|
||||||
|
return result
|
||||||
|
|
||||||
def _get_claim_info(self, name, txid):
|
def _get_claim_info(self, name, txid):
|
||||||
def _build_response(claim):
|
def _build_response(claim):
|
||||||
result = {}
|
|
||||||
try:
|
try:
|
||||||
metadata = Metadata(json.loads(claim['value']))
|
metadata = Metadata(json.loads(claim['value']))
|
||||||
meta_ver = metadata.version
|
meta_ver = metadata.version
|
||||||
|
@ -390,27 +426,12 @@ class LBRYWallet(object):
|
||||||
meta_ver = "Non-compliant"
|
meta_ver = "Non-compliant"
|
||||||
d = defer.succeed(None)
|
d = defer.succeed(None)
|
||||||
|
|
||||||
claim_id = claim['claimId']
|
d.addCallback(lambda _: self._format_claim_for_return(name, claim, txid,
|
||||||
result['claim_id'] = claim_id
|
metadata=metadata, meta_version=meta_ver))
|
||||||
result['amount'] = claim['nEffectiveAmount']
|
log.info("get claim info lbry://%s metadata: %s, claimid: %s", name, meta_ver, claim['claimId'])
|
||||||
result['height'] = claim['nHeight']
|
|
||||||
result['name'] = name
|
|
||||||
result['txid'] = txid
|
|
||||||
result['value'] = metadata
|
|
||||||
result['supports'] = [{'txid': support['txid'], 'n': support['n']} for support in claim['supports']]
|
|
||||||
result['meta_version'] = meta_ver
|
|
||||||
|
|
||||||
log.info("get claim info lbry://%s metadata: %s, claimid: %s", name, meta_ver, claim_id)
|
|
||||||
|
|
||||||
d.addCallback(lambda _: self.get_name_claims())
|
|
||||||
d.addCallback(lambda r: [c['txid'] for c in r])
|
|
||||||
d.addCallback(lambda my_claims: _add_is_mine(result, my_claims))
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _add_is_mine(response, my_txs):
|
|
||||||
response['is_mine'] = response['txid'] in my_txs
|
|
||||||
return response
|
|
||||||
|
|
||||||
d = self.get_claimid(name, txid)
|
d = self.get_claimid(name, txid)
|
||||||
d.addCallback(lambda claim_id: self.get_claim(name, claim_id))
|
d.addCallback(lambda claim_id: self.get_claim(name, claim_id))
|
||||||
d.addCallback(_build_response)
|
d.addCallback(_build_response)
|
||||||
|
|
|
@ -1733,6 +1733,21 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
d.addCallbacks(lambda info: self._render_response(info, OK_CODE), lambda _: server.failure)
|
d.addCallbacks(lambda info: self._render_response(info, OK_CODE), lambda _: server.failure)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def jsonrpc_get_my_claim(self, p):
|
||||||
|
"""
|
||||||
|
Return existing claim for a given name
|
||||||
|
|
||||||
|
Args:
|
||||||
|
'name': name to look up
|
||||||
|
Returns:
|
||||||
|
claim info, False if no such claim exists
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = p['name']
|
||||||
|
d = self.session.wallet.get_my_claim(name)
|
||||||
|
d.addCallback(lambda r: self._render_response(r, OK_CODE))
|
||||||
|
return d
|
||||||
|
|
||||||
def jsonrpc_get_claim_info(self, p):
|
def jsonrpc_get_claim_info(self, p):
|
||||||
"""
|
"""
|
||||||
Resolve claim info from a LBRY uri
|
Resolve claim info from a LBRY uri
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Version=0.4.9
|
Version=0.5.0
|
||||||
Name=LBRY
|
Name=LBRY
|
||||||
Comment=The world's first user-owned content marketplace
|
Comment=The world's first user-owned content marketplace
|
||||||
Icon=lbry
|
Icon=lbry
|
||||||
|
|
|
@ -152,6 +152,15 @@ function addfile() {
|
||||||
echo "$(md5sum "data/$TARGET" | cut -d' ' -f1) $TARGET" >> control/md5sums
|
echo "$(md5sum "data/$TARGET" | cut -d' ' -f1) $TARGET" >> control/md5sums
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addlink() {
|
||||||
|
SRC="$1"
|
||||||
|
TARGET="$2"
|
||||||
|
TMP="$PACKAGING_DIR/lbry-temp-symlink"
|
||||||
|
ln -s "$SRC" "$TMP"
|
||||||
|
addfile "$TMP" "$TARGET"
|
||||||
|
rm "$TMP"
|
||||||
|
}
|
||||||
|
|
||||||
# add icons
|
# add icons
|
||||||
addfile "$PACKAGING_DIR/icons/lbry32.png" usr/share/icons/hicolor/32x32/apps/lbry.png
|
addfile "$PACKAGING_DIR/icons/lbry32.png" usr/share/icons/hicolor/32x32/apps/lbry.png
|
||||||
addfile "$PACKAGING_DIR/icons/lbry48.png" usr/share/icons/hicolor/48x48/apps/lbry.png
|
addfile "$PACKAGING_DIR/icons/lbry48.png" usr/share/icons/hicolor/48x48/apps/lbry.png
|
||||||
|
@ -164,9 +173,10 @@ addfile "$PACKAGING_DIR/lbry.desktop" usr/share/applications/lbry.desktop
|
||||||
BINPATH=usr/share/python/lbrynet/bin
|
BINPATH=usr/share/python/lbrynet/bin
|
||||||
addfile "$PACKAGING_DIR/lbry" "$BINPATH/lbry"
|
addfile "$PACKAGING_DIR/lbry" "$BINPATH/lbry"
|
||||||
|
|
||||||
# symlink script into /usr/bin
|
# symlink scripts into /usr/bin
|
||||||
ln -s "/$BINPATH/lbry" "$PACKAGING_DIR/lbry-temp-symlink"
|
for script in "lbry" "lbrynet-daemon" "lbrynet-cli" "stop-lbrynet-daemon"; do
|
||||||
addfile "$PACKAGING_DIR/lbry-temp-symlink" usr/bin/lbry
|
addlink "/$BINPATH/$script" "usr/bin/$script"
|
||||||
|
done
|
||||||
|
|
||||||
# add lbrycrdd and lbrycrd-cli
|
# add lbrycrdd and lbrycrd-cli
|
||||||
mkdir -p "$PACKAGING_DIR/bins"
|
mkdir -p "$PACKAGING_DIR/bins"
|
||||||
|
|
Loading…
Reference in a new issue