text stringlengths 1 93.6k |
|---|
tx.tx_ins[0]._value = 488779958
|
h160 = BTGTx.get_address_data('GWmfLaQ7ZKmUX7rmW63u63b9ghbuwr9yN1')['h160']
|
tx.tx_ins[0]._script_pubkey = Script.parse(p2pkh_script(h160))
|
tx.tx_ins[1]._value = 969979
|
h160 = BTGTx.get_address_data('GgvZtZ8aV1UhTgLzzRbXVLrwwVoJL9WywW')['h160']
|
tx.tx_ins[1]._script_pubkey = Script.parse(p2pkh_script(h160))
|
self.assertTrue(tx.verify())
|
def test_bcd(self):
|
raw = unhexlify('0c00000025b6923ff3cb4264408ed5d5cca3cc41c7586820c95aeec24503d5a11418dd2501d0b96dd7ff4e3de5113ca48cefcbb4083541154c75e51a2e7b09879301a71cc5000000006a47304402201e10a7a5d03235236475feede87c57a38a79ab3399aafe90fcb9c47de525603b0220547fd8897c0e9d318dbe6c350c784eeb31b3cb18fbf550516fcc0168c22810e501210... |
stream = BytesIO(raw)
|
tx = BCDTx.parse(stream)
|
tx.tx_ins[0]._value = 834614762
|
h160 = BCDTx.get_address_data('1MtE3mjo4AByFJSB8bAuVUHeqb21brLKJ5')['h160']
|
tx.tx_ins[0]._script_pubkey = Script.parse(p2pkh_script(h160))
|
self.assertTrue(tx.verify())
|
def test_sbtc(self):
|
raw = unhexlify('0100000002a81e0df5218289cc4ee761a1747b494990cc1f5b2dc84f0542ad6f28f69d5f4c040000006b483045022100aaf4a05870a9a8ca79a612600936d27bbfce97ebf4e2fe4d311e40c4b78ca6550220175ecff50679023ffce58019ee711784229b8c738b85093d34b4ccc72592087341210313910dbdf4ecfc35f6193b8f6484ab554587f6c7e5e376351e0978e7433d8... |
stream = BytesIO(raw)
|
tx = SBTCTx.parse(stream)
|
tx.tx_ins[0]._value = 67700000
|
h160 = SBTCTx.get_address_data('14fR5g6ypHFx3F9mJwiHaHXkMs5YjS4fJZ')['h160']
|
tx.tx_ins[0]._script_pubkey = Script.parse(p2pkh_script(h160))
|
tx.tx_ins[1]._value = 5300000
|
tx.tx_ins[0]._script_pubkey = Script.parse(p2pkh_script(h160))
|
self.assertTrue(tx.verify())
|
def test_fetch_address_utxos(self):
|
addr = 'mgzCpjQxLVmw89FRrxrZqpzfE33HRAjaSU'
|
utxos = Tx.fetch_address_utxos(addr)
|
total = 0
|
for _, prev_tx, prev_index, value in utxos:
|
total += value
|
self.assertTrue(total > 0)
|
def test_btcp(self):
|
raw = bytes.fromhex('0100000001d5b2052ed9921a83228a9412074425f1b9878588c57cf52961b898d4df345aeb000000008248304502210094d1109cd76909af898aa68c7344a64e18fb7e7a041744a6eecb189f6bdf343802205235353c2fa55c8b087f912511b74350754eb337dbab3b693d1c1232e471b6034121023ec8c89df7dd593314119de90a5535ab8904bef24b3bbd7e459b8cf30... |
stream = BytesIO(raw)
|
tx = BTCPTx.parse(stream)
|
tx.tx_ins[0]._value = 2150000000
|
redeem_script = Script.parse(bytes.fromhex('1600148b8f8534e4164c763bec8e674391eadb4ab82903'))
|
h160 = Script.parse(redeem_script.elements[0]).elements[1]
|
tx.tx_ins[0]._script_pubkey = Script.parse(p2pkh_script(h160))
|
self.assertTrue(tx.verify())
|
# <FILESEP>
|
import logging
|
from json import dumps
|
import structlog
|
from structlog import WriteLoggerFactory
|
from config_reader import LogConfig, LogRenderer
|
def get_structlog_config(
|
log_config: LogConfig
|
) -> dict:
|
"""
|
Get config for structlog
|
:param log_config: объект LogConfig with log parameters
|
:return: dict with structlog config
|
"""
|
# Show debug level logs?
|
if log_config.show_debug_logs is True:
|
min_level = logging.DEBUG
|
else:
|
min_level = logging.INFO
|
return {
|
"processors": get_processors(log_config),
|
"cache_logger_on_first_use": True,
|
"wrapper_class": structlog.make_filtering_bound_logger(min_level),
|
"logger_factory": WriteLoggerFactory()
|
}
|
def get_processors(log_config: LogConfig) -> list:
|
"""
|
Returns processors list for structlog
|
:param log_config: LogConfig object with log parameters
|
:return: processors list for structlog
|
"""
|
def custom_json_serializer(data, *args, **kwargs):
|
"""
|
JSON-objects custom serializer
|
"""
|
result = dict()
|
if log_config.show_datetime is True:
|
result["timestamp"] = data.pop("timestamp")
|
# Other two keys goes in this order
|
for key in ("level", "event"):
|
if key in data:
|
result[key] = data.pop(key)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.