refactor network constants
This commit is contained in:
@@ -7,6 +7,7 @@ try:
|
||||
import electrum
|
||||
from electrum.bitcoin import TYPE_ADDRESS, push_script, var_int, msg_magic, Hash, verify_message, pubkey_from_signature, point_to_ser, public_key_to_p2pkh, EncodeAES, DecodeAES, MyVerifyingKey
|
||||
from electrum.bitcoin import serialize_xpub, deserialize_xpub
|
||||
from electrum import constants
|
||||
from electrum.transaction import Transaction
|
||||
from electrum.i18n import _
|
||||
from electrum.keystore import Hardware_KeyStore
|
||||
@@ -92,10 +93,10 @@ class DigitalBitbox_Client():
|
||||
if reply:
|
||||
xpub = reply['xpub']
|
||||
# Change type of xpub to the requested type. The firmware
|
||||
# only ever returns the standard type, but it is agnostic
|
||||
# only ever returns the mainnet standard type, but it is agnostic
|
||||
# to the type when signing.
|
||||
if xtype != 'standard':
|
||||
_, depth, fingerprint, child_number, c, cK = deserialize_xpub(xpub)
|
||||
if xtype != 'standard' or constants.net.TESTNET:
|
||||
_, depth, fingerprint, child_number, c, cK = deserialize_xpub(xpub, net=constants.BitcoinMainnet)
|
||||
xpub = serialize_xpub(xtype, c, cK, depth, fingerprint, child_number)
|
||||
return xpub
|
||||
else:
|
||||
|
||||
@@ -4,8 +4,9 @@ from binascii import hexlify, unhexlify
|
||||
|
||||
from electrum.util import bfh, bh2u
|
||||
from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey,
|
||||
TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants,
|
||||
TYPE_ADDRESS, TYPE_SCRIPT,
|
||||
is_segwit_address)
|
||||
from electrum import constants
|
||||
from electrum.i18n import _
|
||||
from electrum.plugins import BasePlugin
|
||||
from electrum.transaction import deserialize
|
||||
@@ -139,7 +140,7 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
|
||||
return client
|
||||
|
||||
def get_coin_name(self):
|
||||
return "Testnet" if NetworkConstants.TESTNET else "Bitcoin"
|
||||
return "Testnet" if constants.net.TESTNET else "Bitcoin"
|
||||
|
||||
def initialize_device(self, device_id, wizard, handler):
|
||||
# Initialization method
|
||||
@@ -344,9 +345,9 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
|
||||
txoutputtype.script_type = self.types.PAYTOWITNESS
|
||||
else:
|
||||
addrtype, hash_160 = b58_address_to_hash160(address)
|
||||
if addrtype == NetworkConstants.ADDRTYPE_P2PKH:
|
||||
if addrtype == constants.net.ADDRTYPE_P2PKH:
|
||||
txoutputtype.script_type = self.types.PAYTOADDRESS
|
||||
elif addrtype == NetworkConstants.ADDRTYPE_P2SH:
|
||||
elif addrtype == constants.net.ADDRTYPE_P2SH:
|
||||
txoutputtype.script_type = self.types.PAYTOSCRIPTHASH
|
||||
else:
|
||||
raise BaseException('addrtype: ' + str(addrtype))
|
||||
|
||||
@@ -4,7 +4,8 @@ from binascii import hexlify, unhexlify
|
||||
|
||||
from electrum.util import bfh, bh2u, versiontuple
|
||||
from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey,
|
||||
TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants)
|
||||
TYPE_ADDRESS, TYPE_SCRIPT)
|
||||
from electrum import constants
|
||||
from electrum.i18n import _
|
||||
from electrum.plugins import BasePlugin, Device
|
||||
from electrum.transaction import deserialize
|
||||
@@ -173,7 +174,7 @@ class TrezorPlugin(HW_PluginBase):
|
||||
return client
|
||||
|
||||
def get_coin_name(self):
|
||||
return "Testnet" if NetworkConstants.TESTNET else "Bitcoin"
|
||||
return "Testnet" if constants.net.TESTNET else "Bitcoin"
|
||||
|
||||
def initialize_device(self, device_id, wizard, handler):
|
||||
# Initialization method
|
||||
|
||||
@@ -32,6 +32,7 @@ from urllib.parse import quote
|
||||
|
||||
import electrum
|
||||
from electrum import bitcoin
|
||||
from electrum import constants
|
||||
from electrum import keystore
|
||||
from electrum.bitcoin import *
|
||||
from electrum.mnemonic import Mnemonic
|
||||
@@ -44,13 +45,13 @@ from electrum.storage import STO_EV_USER_PW
|
||||
|
||||
# signing_xpub is hardcoded so that the wallet can be restored from seed, without TrustedCoin's server
|
||||
def get_signing_xpub():
|
||||
if NetworkConstants.TESTNET:
|
||||
if constants.net.TESTNET:
|
||||
return "tpubD6NzVbkrYhZ4XdmyJQcCPjQfg6RXVUzGFhPjZ7uvRC8JLcS7Hw1i7UTpyhp9grHpak4TyK2hzBJrujDVLXQ6qB5tNpVx9rC6ixijUXadnmY"
|
||||
else:
|
||||
return "xpub661MyMwAqRbcGnMkaTx2594P9EDuiEqMq25PM2aeG6UmwzaohgA6uDmNsvSUV8ubqwA3Wpste1hg69XHgjUuCD5HLcEp2QPzyV1HMrPppsL"
|
||||
|
||||
def get_billing_xpub():
|
||||
if NetworkConstants.TESTNET:
|
||||
if constants.net.TESTNET:
|
||||
return "tpubD6NzVbkrYhZ4X11EJFTJujsYbUmVASAYY7gXsEt4sL97AMBdypiH1E9ZVTpdXXEy3Kj9Eqd1UkxdGtvDt5z23DKsh6211CfNJo8bLLyem5r"
|
||||
else:
|
||||
return "xpub6DTBdtBB8qUmH5c77v8qVGVoYk7WjJNpGvutqjLasNG1mbux6KsojaLrYf2sRhXAVU4NaFuHhbD9SvVPRt1MB1MaMooRuhHcAZH1yhQ1qDU"
|
||||
|
||||
Reference in New Issue
Block a user