From e74998209dc08c70bfaec809236fa5aae08e6d88 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Wed, 20 Mar 2019 17:31:00 -0400 Subject: [PATCH] for victor --- lbrynet/extras/daemon/json_response_encoder.py | 3 +++ lbrynet/wallet/resolve.py | 5 +++-- lbrynet/wallet/transaction.py | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lbrynet/extras/daemon/json_response_encoder.py b/lbrynet/extras/daemon/json_response_encoder.py index d8cb0b37d..6dd44bfd4 100644 --- a/lbrynet/extras/daemon/json_response_encoder.py +++ b/lbrynet/extras/daemon/json_response_encoder.py @@ -4,6 +4,7 @@ from binascii import hexlify from datetime import datetime from json import JSONEncoder from ecdsa import BadSignatureError +from lbrynet.schema.claim import Claim from lbrynet.wallet.ledger import MainNetLedger from lbrynet.wallet.transaction import Transaction, Output from lbrynet.wallet.dewies import dewies_to_lbc @@ -23,6 +24,8 @@ class JSONResponseEncoder(JSONEncoder): return self.encode_transaction(obj) if isinstance(obj, Output): return self.encode_output(obj) + if isinstance(obj, Claim): + return obj.to_dict() if isinstance(obj, datetime): return obj.strftime("%Y%m%dT%H:%M:%S") if isinstance(obj, Decimal): diff --git a/lbrynet/wallet/resolve.py b/lbrynet/wallet/resolve.py index c2e60c304..3b3fbe5fc 100644 --- a/lbrynet/wallet/resolve.py +++ b/lbrynet/wallet/resolve.py @@ -167,7 +167,7 @@ class Resolver: if not raw: claim_value = claim_result['value'] try: - decoded = claim_result['value'] = Claim.from_bytes(claim_value) + decoded = claim_result['value'] = Claim.from_bytes(unhexlify(claim_value)) claim_result['decoded_claim'] = True except DecodeError: pass @@ -427,7 +427,8 @@ def _decode_claim_result(claim): claim['error'] = "Failed to parse: missing value." + backend_message return claim try: - claim['value'] = Claim.from_bytes(claim['value']) + if not isinstance(claim['value'], Claim): + claim['value'] = Claim.from_bytes(claim['value']) claim['hex'] = hexlify(claim['value'].to_bytes()) except DecodeError: claim['hex'] = claim['value'] diff --git a/lbrynet/wallet/transaction.py b/lbrynet/wallet/transaction.py index 5fdd194f1..eb037567f 100644 --- a/lbrynet/wallet/transaction.py +++ b/lbrynet/wallet/transaction.py @@ -122,6 +122,7 @@ class Output(BaseOutput): ])) private_key = ecdsa.SigningKey.from_pem(channel.private_key, hashfunc=hashlib.sha256) self.claim.signature = private_key.sign_digest_deterministic(digest, hashfunc=hashlib.sha256) + self.script.generate() def generate_channel_private_key(self): private_key = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256)