move common schema values to constants.py

This commit is contained in:
Victor Shyba 2019-02-28 18:54:37 -03:00 committed by Lex Berezhny
parent 9b64ee33dc
commit 291d65070d
13 changed files with 73 additions and 69 deletions

View file

@ -6,7 +6,7 @@ from binascii import unhexlify
from datetime import datetime
from typing import Optional
from lbrynet.schema.legacy_schema_v1 import SECP256k1
from lbrynet.schema.constants import SECP256k1
from torba.client.basemanager import BaseWalletManager
from torba.rpc.jsonrpc import CodeMessageError

View file

@ -2,7 +2,7 @@ import lbrynet.schema
from lbrynet.schema.base import b58encode, b58decode, validate_b58_checksum
from lbrynet.schema.hashing import double_sha256, hash160
from lbrynet.schema.error import InvalidAddress
from lbrynet.schema.legacy_schema_v1 import ADDRESS_LENGTH, ADDRESS_PREFIXES, PUBKEY_ADDRESS, SCRIPT_ADDRESS
from lbrynet.schema.constants import ADDRESS_LENGTH, ADDRESS_PREFIXES, PUBKEY_ADDRESS, SCRIPT_ADDRESS
def validate_address_length(addr_bytes):

View file

@ -1,4 +1,4 @@
from lbrynet.schema.legacy_schema_v1 import ADDRESS_CHECKSUM_LENGTH
from lbrynet.schema.constants import ADDRESS_CHECKSUM_LENGTH
from lbrynet.schema.hashing import double_sha256
from lbrynet.schema.error import InvalidAddress

View file

@ -10,7 +10,8 @@ from lbrynet.schema.signature import Signature
from lbrynet.schema.validator import get_validator
from lbrynet.schema.signer import get_signer
from lbrynet.schema.legacy_schema_v1.claim import Claim
from lbrynet.schema.legacy_schema_v1 import CURVE_NAMES, CLAIM_TYPE_NAMES, SECP256k1
from lbrynet.schema.legacy_schema_v1 import CLAIM_TYPE_NAMES
from lbrynet.schema.constants import CURVE_NAMES, SECP256k1
from lbrynet.schema.encoding import decode_fields, decode_b64_fields, encode_fields
from lbrynet.schema.error import DecodeError
from lbrynet.schema.fee import Fee

View file

@ -0,0 +1,58 @@
LBC = "LBC"
BTC = "BTC"
USD = "USD"
CURRENCY_MAP = {
LBC: 1,
BTC: 2,
USD: 3
}
CURRENCY_NAMES = {
1: LBC,
2: BTC,
3: USD
}
ADDRESS_LENGTH = 25
ADDRESS_CHECKSUM_LENGTH = 4
NIST256p = "NIST256p"
NIST384p = "NIST384p"
SECP256k1 = "SECP256k1"
ECDSA_CURVES = {
NIST256p: 1,
NIST384p: 2,
SECP256k1: 3
}
CURVE_NAMES = {
1: NIST256p,
2: NIST384p,
3: SECP256k1
}
SHA256 = "sha256"
SHA384 = "sha384"
B58_CHARS = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
assert len(B58_CHARS) == 58
PUBKEY_ADDRESS = 0
SCRIPT_ADDRESS = 5
ADDRESS_PREFIXES = {
"lbrycrd_main": {
PUBKEY_ADDRESS: 85,
SCRIPT_ADDRESS: 122
},
"lbrycrd_regtest": {
PUBKEY_ADDRESS: 111,
SCRIPT_ADDRESS: 196
},
"lbrycrd_testnet": {
PUBKEY_ADDRESS: 111,
SCRIPT_ADDRESS: 196
},
}

View file

@ -1,7 +1,7 @@
from collections import OrderedDict
from lbrynet.schema.address import encode_address, decode_address
from lbrynet.schema.legacy_schema_v1 import CURRENCY_NAMES, CURRENCY_MAP
from lbrynet.schema.constants import CURRENCY_NAMES, CURRENCY_MAP
from lbrynet.schema.legacy_schema_v1.fee import Fee as FeeHelper
from lbrynet.schema.proto2 import fee_pb2

View file

@ -18,24 +18,6 @@ VERSION_NAMES = {
4: V_0_1_0
}
LBC = "LBC"
BTC = "BTC"
USD = "USD"
CURRENCY_MAP = {
LBC: 1,
BTC: 2,
USD: 3
}
CURRENCY_NAMES = {
1: LBC,
2: BTC,
3: USD
}
ADDRESS_LENGTH = 25
ADDRESS_CHECKSUM_LENGTH = 4
VERSION = "version"
STREAM_TYPE = "streamType"
@ -60,43 +42,3 @@ SOURCE_TYPES = {
LBRY_SD_HASH: 1
}
NIST256p = "NIST256p"
NIST384p = "NIST384p"
SECP256k1 = "SECP256k1"
ECDSA_CURVES = {
NIST256p: 1,
NIST384p: 2,
SECP256k1: 3
}
CURVE_NAMES = {
1: NIST256p,
2: NIST384p,
3: SECP256k1
}
SHA256 = "sha256"
SHA384 = "sha384"
B58_CHARS = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
assert len(B58_CHARS) == 58
PUBKEY_ADDRESS = 0
SCRIPT_ADDRESS = 5
ADDRESS_PREFIXES = {
"lbrycrd_main": {
PUBKEY_ADDRESS: 85,
SCRIPT_ADDRESS: 122
},
"lbrycrd_regtest": {
PUBKEY_ADDRESS: 111,
SCRIPT_ADDRESS: 196
},
"lbrycrd_testnet": {
PUBKEY_ADDRESS: 111,
SCRIPT_ADDRESS: 196
},
}

View file

@ -2,7 +2,8 @@ from copy import deepcopy
from lbrynet.schema.proto2 import certificate_pb2 as cert_pb
from lbrynet.schema.legacy_schema_v1.schema import Schema
from lbrynet.schema.legacy_schema_v1 import VERSION_MAP, V_0_0_1, ECDSA_CURVES, CURVE_NAMES
from lbrynet.schema.legacy_schema_v1 import VERSION_MAP, V_0_0_1
from lbrynet.schema.constants import ECDSA_CURVES, CURVE_NAMES
from lbrynet.schema.validator import get_key_type_from_dem

View file

@ -2,7 +2,8 @@ from copy import deepcopy
from lbrynet.schema.proto2 import fee_pb2 as fee_pb
from lbrynet.schema.legacy_schema_v1.schema import Schema
from lbrynet.schema.legacy_schema_v1 import VERSION_MAP, CURRENCY_MAP
from lbrynet.schema.legacy_schema_v1 import VERSION_MAP
from lbrynet.schema.constants import CURRENCY_MAP
class Fee(Schema):

View file

@ -1,7 +1,8 @@
from copy import deepcopy
from lbrynet.schema.proto2 import signature_pb2 as signature_pb
from lbrynet.schema.legacy_schema_v1 import VERSION_MAP, ECDSA_CURVES
from lbrynet.schema.legacy_schema_v1 import VERSION_MAP
from lbrynet.schema.constants import ECDSA_CURVES
from lbrynet.schema.legacy_schema_v1.schema import Schema

View file

@ -8,7 +8,7 @@ from lbrynet.schema.validator import validate_claim_id
from lbrynet.schema.legacy_schema_v1.certificate import Certificate
from lbrynet.schema.legacy_schema_v1.claim import Claim
from lbrynet.schema.legacy_schema_v1 import V_0_0_1, CLAIM_TYPE, CLAIM_TYPES, CERTIFICATE_TYPE, VERSION
from lbrynet.schema.legacy_schema_v1 import NIST256p, NIST384p, SECP256k1, SHA256, SHA384
from lbrynet.schema.constants import NIST256p, NIST384p, SECP256k1, SHA256, SHA384
class NIST_ECDSASigner(object):

View file

@ -13,7 +13,7 @@ from cryptography.exceptions import InvalidSignature
from ecdsa.util import sigencode_der
from lbrynet.schema.address import decode_address
from lbrynet.schema.legacy_schema_v1 import NIST256p, NIST384p, SECP256k1, ECDSA_CURVES, CURVE_NAMES
from lbrynet.schema.constants import NIST256p, NIST384p, SECP256k1, ECDSA_CURVES, CURVE_NAMES
def validate_claim_id(claim_id):

View file

@ -16,7 +16,7 @@ from .test_data import secp256k1_private_key, claim_010_signed_secp256k1, secp25
from .test_data import hex_encoded_003, decoded_hex_encoded_003, malformed_secp256k1_cert
from lbrynet import schema
from lbrynet.schema.claim import ClaimDict
from lbrynet.schema.legacy_schema_v1 import NIST256p, NIST384p, SECP256k1
from lbrynet.schema.constants import NIST256p, NIST384p, SECP256k1
from lbrynet.schema.legacy.migrate import migrate
from lbrynet.schema.signer import get_signer
from lbrynet.schema.uri import URI, URIParseError