hive-nectar 0.0.6__py3-none-any.whl → 0.0.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hive-nectar might be problematic. Click here for more details.
- {hive_nectar-0.0.6.dist-info → hive_nectar-0.0.7.dist-info}/METADATA +5 -3
- {hive_nectar-0.0.6.dist-info → hive_nectar-0.0.7.dist-info}/RECORD +46 -47
- nectar/account.py +43 -47
- nectar/amount.py +6 -11
- nectar/block.py +8 -9
- nectar/blockchain.py +4 -5
- nectar/blockchaininstance.py +4 -4
- nectar/blockchainobject.py +5 -6
- nectar/blurt.py +3 -4
- nectar/cli.py +14 -14
- nectar/comment.py +10 -11
- nectar/community.py +4 -5
- nectar/conveyor.py +3 -4
- nectar/exceptions.py +30 -24
- nectar/hive.py +3 -4
- nectar/hivesigner.py +2 -2
- nectar/imageuploader.py +2 -3
- nectar/price.py +6 -13
- nectar/rc.py +1 -2
- nectar/steem.py +3 -4
- nectar/transactionbuilder.py +12 -3
- nectar/version.py +1 -1
- nectar/vote.py +8 -9
- nectar/wallet.py +1 -1
- nectarapi/exceptions.py +20 -14
- nectarapi/version.py +1 -1
- nectarbase/ledgertransactions.py +2 -3
- nectarbase/memo.py +9 -10
- nectarbase/objects.py +4 -5
- nectarbase/operations.py +3 -7
- nectarbase/version.py +1 -1
- nectargraphenebase/__init__.py +0 -1
- nectargraphenebase/account.py +16 -37
- nectargraphenebase/base58.py +5 -8
- nectargraphenebase/bip32.py +5 -11
- nectargraphenebase/bip38.py +6 -7
- nectargraphenebase/ecdsasig.py +32 -37
- nectargraphenebase/objects.py +6 -7
- nectargraphenebase/signedtransactions.py +10 -9
- nectargraphenebase/types.py +9 -19
- nectargraphenebase/unsignedtransactions.py +21 -28
- nectargraphenebase/version.py +1 -1
- nectarstorage/masterpassword.py +2 -3
- nectargraphenebase/py23.py +0 -38
- {hive_nectar-0.0.6.dist-info → hive_nectar-0.0.7.dist-info}/WHEEL +0 -0
- {hive_nectar-0.0.6.dist-info → hive_nectar-0.0.7.dist-info}/entry_points.txt +0 -0
- {hive_nectar-0.0.6.dist-info → hive_nectar-0.0.7.dist-info}/licenses/LICENSE.txt +0 -0
nectar/imageuploader.py
CHANGED
|
@@ -6,7 +6,6 @@ import requests
|
|
|
6
6
|
|
|
7
7
|
from nectar.account import Account
|
|
8
8
|
from nectargraphenebase.ecdsasig import sign_message
|
|
9
|
-
from nectargraphenebase.py23 import py23_bytes, string_types
|
|
10
9
|
|
|
11
10
|
from .instance import shared_blockchain_instance
|
|
12
11
|
|
|
@@ -55,14 +54,14 @@ class ImageUploader(object):
|
|
|
55
54
|
for authority in account["posting"]["key_auths"]:
|
|
56
55
|
posting_wif = self.steem.wallet.getPrivateKeyForPublicKey(authority[0])
|
|
57
56
|
|
|
58
|
-
if isinstance(image,
|
|
57
|
+
if isinstance(image, str):
|
|
59
58
|
image_data = open(image, "rb").read()
|
|
60
59
|
elif isinstance(image, io.BytesIO):
|
|
61
60
|
image_data = image.read()
|
|
62
61
|
else:
|
|
63
62
|
image_data = image
|
|
64
63
|
|
|
65
|
-
message =
|
|
64
|
+
message = bytes(self.challenge, "ascii") + image_data
|
|
66
65
|
signature = sign_message(message, posting_wif)
|
|
67
66
|
signature_in_hex = hexlify(signature).decode("ascii")
|
|
68
67
|
|
nectar/price.py
CHANGED
|
@@ -3,7 +3,6 @@ from decimal import Decimal
|
|
|
3
3
|
from fractions import Fraction
|
|
4
4
|
|
|
5
5
|
from nectar.instance import shared_blockchain_instance
|
|
6
|
-
from nectargraphenebase.py23 import integer_types, string_types
|
|
7
6
|
|
|
8
7
|
from .amount import Amount
|
|
9
8
|
from .asset import Asset
|
|
@@ -97,7 +96,7 @@ class Price(dict):
|
|
|
97
96
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
98
97
|
if price == "":
|
|
99
98
|
price = None
|
|
100
|
-
if price is not None and isinstance(price,
|
|
99
|
+
if price is not None and isinstance(price, str) and not base and not quote:
|
|
101
100
|
price, assets = price.split(" ")
|
|
102
101
|
base_symbol, quote_symbol = assets_from_string(assets)
|
|
103
102
|
base = Asset(base_symbol, blockchain_instance=self.blockchain)
|
|
@@ -131,9 +130,7 @@ class Price(dict):
|
|
|
131
130
|
amount=frac.numerator, asset=base, blockchain_instance=self.blockchain
|
|
132
131
|
)
|
|
133
132
|
|
|
134
|
-
elif (
|
|
135
|
-
price is not None and isinstance(base, string_types) and isinstance(quote, string_types)
|
|
136
|
-
):
|
|
133
|
+
elif price is not None and isinstance(base, str) and isinstance(quote, str):
|
|
137
134
|
base = Asset(base, blockchain_instance=self.blockchain)
|
|
138
135
|
quote = Asset(quote, blockchain_instance=self.blockchain)
|
|
139
136
|
frac = Fraction(float(price)).limit_denominator(10 ** base["precision"])
|
|
@@ -144,12 +141,10 @@ class Price(dict):
|
|
|
144
141
|
amount=frac.numerator, asset=base, blockchain_instance=self.blockchain
|
|
145
142
|
)
|
|
146
143
|
|
|
147
|
-
elif price is None and isinstance(base,
|
|
144
|
+
elif price is None and isinstance(base, str) and isinstance(quote, str):
|
|
148
145
|
self["quote"] = Amount(quote, blockchain_instance=self.blockchain)
|
|
149
146
|
self["base"] = Amount(base, blockchain_instance=self.blockchain)
|
|
150
|
-
elif (
|
|
151
|
-
price is not None and isinstance(price, string_types) and isinstance(base, string_types)
|
|
152
|
-
):
|
|
147
|
+
elif price is not None and isinstance(price, str) and isinstance(base, str):
|
|
153
148
|
self["quote"] = Amount(price, blockchain_instance=self.blockchain)
|
|
154
149
|
self["base"] = Amount(base, blockchain_instance=self.blockchain)
|
|
155
150
|
# len(args) > 1
|
|
@@ -163,10 +158,8 @@ class Price(dict):
|
|
|
163
158
|
self["base"] = base
|
|
164
159
|
|
|
165
160
|
elif (
|
|
166
|
-
isinstance(price, float)
|
|
167
|
-
|
|
168
|
-
or isinstance(price, Decimal)
|
|
169
|
-
) and isinstance(base, string_types):
|
|
161
|
+
isinstance(price, float) or isinstance(price, int) or isinstance(price, Decimal)
|
|
162
|
+
) and isinstance(base, str):
|
|
170
163
|
base_symbol, quote_symbol = assets_from_string(base)
|
|
171
164
|
base = Asset(base_symbol, blockchain_instance=self.blockchain)
|
|
172
165
|
quote = Asset(quote_symbol, blockchain_instance=self.blockchain)
|
nectar/rc.py
CHANGED
|
@@ -9,7 +9,6 @@ from nectar.constants import (
|
|
|
9
9
|
from nectarbase import operations
|
|
10
10
|
from nectarbase.objects import Operation
|
|
11
11
|
from nectarbase.signedtransactions import Signed_Transaction
|
|
12
|
-
from nectargraphenebase.py23 import py23_bytes
|
|
13
12
|
|
|
14
13
|
from .instance import shared_blockchain_instance
|
|
15
14
|
|
|
@@ -38,7 +37,7 @@ class RC(object):
|
|
|
38
37
|
operations=ops,
|
|
39
38
|
)
|
|
40
39
|
tx = tx.sign([wif], chain=prefix)
|
|
41
|
-
txWire = hexlify(
|
|
40
|
+
txWire = hexlify(bytes(tx)).decode("ascii")
|
|
42
41
|
tx_size = len(txWire)
|
|
43
42
|
return tx_size
|
|
44
43
|
|
nectar/steem.py
CHANGED
|
@@ -6,7 +6,6 @@ from datetime import date, datetime, timezone
|
|
|
6
6
|
from nectar.blockchaininstance import BlockChainInstance
|
|
7
7
|
from nectar.constants import STEEM_100_PERCENT, STEEM_VOTE_REGENERATION_SECONDS
|
|
8
8
|
from nectargraphenebase.chains import known_chains
|
|
9
|
-
from nectargraphenebase.py23 import string_types
|
|
10
9
|
|
|
11
10
|
from .amount import Amount
|
|
12
11
|
from .utils import formatToTimeStamp
|
|
@@ -124,7 +123,7 @@ class Steem(BlockChainInstance):
|
|
|
124
123
|
return known_chains["STEEM"]
|
|
125
124
|
try:
|
|
126
125
|
return self.rpc.get_network(props=config)
|
|
127
|
-
except:
|
|
126
|
+
except Exception:
|
|
128
127
|
return known_chains["STEEM"]
|
|
129
128
|
|
|
130
129
|
def rshares_to_token_backed_dollar(
|
|
@@ -393,7 +392,7 @@ class Steem(BlockChainInstance):
|
|
|
393
392
|
"""
|
|
394
393
|
if isinstance(sbd, Amount):
|
|
395
394
|
sbd = Amount(sbd, blockchain_instance=self)
|
|
396
|
-
elif isinstance(sbd,
|
|
395
|
+
elif isinstance(sbd, str):
|
|
397
396
|
sbd = Amount(sbd, blockchain_instance=self)
|
|
398
397
|
else:
|
|
399
398
|
sbd = Amount(sbd, self.sbd_symbol, blockchain_instance=self)
|
|
@@ -517,7 +516,7 @@ class Steem(BlockChainInstance):
|
|
|
517
516
|
"""
|
|
518
517
|
if isinstance(sbd, Amount):
|
|
519
518
|
sbd = Amount(sbd, blockchain_instance=self)
|
|
520
|
-
elif isinstance(sbd,
|
|
519
|
+
elif isinstance(sbd, str):
|
|
521
520
|
sbd = Amount(sbd, blockchain_instance=self)
|
|
522
521
|
else:
|
|
523
522
|
sbd = Amount(sbd, self.sbd_symbol, blockchain_instance=self)
|
nectar/transactionbuilder.py
CHANGED
|
@@ -279,7 +279,7 @@ class TransactionBuilder(dict):
|
|
|
279
279
|
try:
|
|
280
280
|
PrivateKey(wif, prefix=self.blockchain.prefix)
|
|
281
281
|
self.wifs.add(wif)
|
|
282
|
-
except:
|
|
282
|
+
except Exception:
|
|
283
283
|
raise InvalidWifError
|
|
284
284
|
|
|
285
285
|
def clearWifs(self):
|
|
@@ -427,7 +427,7 @@ class TransactionBuilder(dict):
|
|
|
427
427
|
# try:
|
|
428
428
|
# ledgertx = Ledger_Transaction(**self.json(with_prefix=True))
|
|
429
429
|
# ledgertx.add_custom_chains(self.blockchain.custom_chains)
|
|
430
|
-
# except:
|
|
430
|
+
# except Exception:
|
|
431
431
|
# raise ValueError("Invalid TransactionBuilder Format")
|
|
432
432
|
# ledgertx.sign(self.path, chain=self.blockchain.chain_params)
|
|
433
433
|
self.ledgertx.sign(self.path, chain=self.blockchain.chain_params)
|
|
@@ -438,7 +438,16 @@ class TransactionBuilder(dict):
|
|
|
438
438
|
raise MissingKeyError
|
|
439
439
|
|
|
440
440
|
self.tx.sign(self.wifs, chain=self.blockchain.chain_params)
|
|
441
|
-
self["signatures"]
|
|
441
|
+
# Defensive: ensure self["signatures"] is a list before extend
|
|
442
|
+
if isinstance(self["signatures"], str):
|
|
443
|
+
log.warning(
|
|
444
|
+
"self['signatures'] was a string, converting to list to avoid AttributeError."
|
|
445
|
+
)
|
|
446
|
+
self["signatures"] = [self["signatures"]]
|
|
447
|
+
sigs = self.tx.json().get("signatures")
|
|
448
|
+
if isinstance(sigs, str):
|
|
449
|
+
sigs = [sigs]
|
|
450
|
+
self["signatures"].extend(sigs)
|
|
442
451
|
return self.tx
|
|
443
452
|
|
|
444
453
|
def verify_authority(self):
|
nectar/version.py
CHANGED
nectar/vote.py
CHANGED
|
@@ -5,7 +5,6 @@ from datetime import date, datetime, timezone
|
|
|
5
5
|
from prettytable import PrettyTable
|
|
6
6
|
|
|
7
7
|
from nectarapi.exceptions import InvalidParameters, UnknownKey
|
|
8
|
-
from nectargraphenebase.py23 import integer_types, string_types
|
|
9
8
|
|
|
10
9
|
from .account import Account
|
|
11
10
|
from .blockchainobject import BlockchainObject
|
|
@@ -42,7 +41,7 @@ class Vote(BlockchainObject):
|
|
|
42
41
|
elif kwargs.get("hive_instance"):
|
|
43
42
|
blockchain_instance = kwargs["hive_instance"]
|
|
44
43
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
45
|
-
if isinstance(voter,
|
|
44
|
+
if isinstance(voter, str) and authorperm is not None:
|
|
46
45
|
[author, permlink] = resolve_authorperm(authorperm)
|
|
47
46
|
self["voter"] = voter
|
|
48
47
|
self["author"] = author
|
|
@@ -138,20 +137,20 @@ class Vote(BlockchainObject):
|
|
|
138
137
|
"reputation",
|
|
139
138
|
]
|
|
140
139
|
for p in parse_int:
|
|
141
|
-
if p in vote and isinstance(vote.get(p),
|
|
140
|
+
if p in vote and isinstance(vote.get(p), str):
|
|
142
141
|
vote[p] = int(vote.get(p, "0"))
|
|
143
142
|
|
|
144
|
-
if "time" in vote and isinstance(vote.get("time"),
|
|
143
|
+
if "time" in vote and isinstance(vote.get("time"), str) and vote.get("time") != "":
|
|
145
144
|
vote["time"] = formatTimeString(vote.get("time", "1970-01-01T00:00:00"))
|
|
146
145
|
elif (
|
|
147
146
|
"timestamp" in vote
|
|
148
|
-
and isinstance(vote.get("timestamp"),
|
|
147
|
+
and isinstance(vote.get("timestamp"), str)
|
|
149
148
|
and vote.get("timestamp") != ""
|
|
150
149
|
):
|
|
151
150
|
vote["time"] = formatTimeString(vote.get("timestamp", "1970-01-01T00:00:00"))
|
|
152
151
|
elif (
|
|
153
152
|
"last_update" in vote
|
|
154
|
-
and isinstance(vote.get("last_update"),
|
|
153
|
+
and isinstance(vote.get("last_update"), str)
|
|
155
154
|
and vote.get("last_update") != ""
|
|
156
155
|
):
|
|
157
156
|
vote["last_update"] = formatTimeString(vote.get("last_update", "1970-01-01T00:00:00"))
|
|
@@ -178,7 +177,7 @@ class Vote(BlockchainObject):
|
|
|
178
177
|
"reputation",
|
|
179
178
|
]
|
|
180
179
|
for p in parse_int:
|
|
181
|
-
if p in output and isinstance(output[p],
|
|
180
|
+
if p in output and isinstance(output[p], int):
|
|
182
181
|
output[p] = str(output[p])
|
|
183
182
|
return json.loads(str(json.dumps(output)))
|
|
184
183
|
|
|
@@ -456,7 +455,7 @@ class ActiveVotes(VotesObject):
|
|
|
456
455
|
authorperm["author"], authorperm["permlink"], api="condenser"
|
|
457
456
|
)
|
|
458
457
|
authorperm = authorperm["authorperm"]
|
|
459
|
-
elif isinstance(authorperm,
|
|
458
|
+
elif isinstance(authorperm, str):
|
|
460
459
|
[author, permlink] = resolve_authorperm(authorperm)
|
|
461
460
|
if self.blockchain.rpc.get_use_appbase():
|
|
462
461
|
self.blockchain.rpc.set_next_node_on_empty_reply(False)
|
|
@@ -534,7 +533,7 @@ class AccountVotes(VotesObject):
|
|
|
534
533
|
time = x.get("last_update", "")
|
|
535
534
|
if time != "":
|
|
536
535
|
x["time"] = time
|
|
537
|
-
if time != "" and isinstance(time,
|
|
536
|
+
if time != "" and isinstance(time, str):
|
|
538
537
|
d_time = formatTimeString(time)
|
|
539
538
|
elif isinstance(time, datetime):
|
|
540
539
|
d_time = time
|
nectar/wallet.py
CHANGED
nectarapi/exceptions.py
CHANGED
|
@@ -19,37 +19,43 @@ def decodeRPCErrorMsg(e):
|
|
|
19
19
|
return str(e)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class
|
|
22
|
+
class NectarApiException(Exception):
|
|
23
|
+
"""NectarApiException base Exception."""
|
|
24
|
+
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class UnauthorizedError(NectarApiException):
|
|
23
29
|
"""UnauthorizedError Exception."""
|
|
24
30
|
|
|
25
31
|
pass
|
|
26
32
|
|
|
27
33
|
|
|
28
|
-
class RPCConnection(
|
|
34
|
+
class RPCConnection(NectarApiException):
|
|
29
35
|
"""RPCConnection Exception."""
|
|
30
36
|
|
|
31
37
|
pass
|
|
32
38
|
|
|
33
39
|
|
|
34
|
-
class RPCError(
|
|
40
|
+
class RPCError(NectarApiException):
|
|
35
41
|
"""RPCError Exception."""
|
|
36
42
|
|
|
37
43
|
pass
|
|
38
44
|
|
|
39
45
|
|
|
40
|
-
class RPCErrorDoRetry(
|
|
46
|
+
class RPCErrorDoRetry(NectarApiException):
|
|
41
47
|
"""RPCErrorDoRetry Exception."""
|
|
42
48
|
|
|
43
49
|
pass
|
|
44
50
|
|
|
45
51
|
|
|
46
|
-
class NumRetriesReached(
|
|
52
|
+
class NumRetriesReached(NectarApiException):
|
|
47
53
|
"""NumRetriesReached Exception."""
|
|
48
54
|
|
|
49
55
|
pass
|
|
50
56
|
|
|
51
57
|
|
|
52
|
-
class CallRetriesReached(
|
|
58
|
+
class CallRetriesReached(NectarApiException):
|
|
53
59
|
"""CallRetriesReached Exception. Only for internal use"""
|
|
54
60
|
|
|
55
61
|
pass
|
|
@@ -91,33 +97,33 @@ class FilteredItemNotFound(RPCError):
|
|
|
91
97
|
pass
|
|
92
98
|
|
|
93
99
|
|
|
94
|
-
class InvalidEndpointUrl(
|
|
100
|
+
class InvalidEndpointUrl(NectarApiException):
|
|
95
101
|
pass
|
|
96
102
|
|
|
97
103
|
|
|
98
|
-
class InvalidParameters(
|
|
104
|
+
class InvalidParameters(NectarApiException):
|
|
99
105
|
pass
|
|
100
106
|
|
|
101
107
|
|
|
102
|
-
class SupportedByHivemind(
|
|
108
|
+
class SupportedByHivemind(NectarApiException):
|
|
103
109
|
pass
|
|
104
110
|
|
|
105
111
|
|
|
106
|
-
class UnnecessarySignatureDetected(
|
|
112
|
+
class UnnecessarySignatureDetected(NectarApiException):
|
|
107
113
|
pass
|
|
108
114
|
|
|
109
115
|
|
|
110
|
-
class WorkingNodeMissing(
|
|
116
|
+
class WorkingNodeMissing(NectarApiException):
|
|
111
117
|
pass
|
|
112
118
|
|
|
113
119
|
|
|
114
|
-
class TimeoutException(
|
|
120
|
+
class TimeoutException(NectarApiException):
|
|
115
121
|
pass
|
|
116
122
|
|
|
117
123
|
|
|
118
|
-
class VotedBeforeWaitTimeReached(
|
|
124
|
+
class VotedBeforeWaitTimeReached(NectarApiException):
|
|
119
125
|
pass
|
|
120
126
|
|
|
121
127
|
|
|
122
|
-
class UnknownTransaction(
|
|
128
|
+
class UnknownTransaction(NectarApiException):
|
|
123
129
|
pass
|
nectarapi/version.py
CHANGED
nectarbase/ledgertransactions.py
CHANGED
|
@@ -3,7 +3,6 @@ import logging
|
|
|
3
3
|
|
|
4
4
|
from nectargraphenebase.account import PublicKey
|
|
5
5
|
from nectargraphenebase.chains import known_chains
|
|
6
|
-
from nectargraphenebase.py23 import py23_bytes
|
|
7
6
|
from nectargraphenebase.types import (
|
|
8
7
|
Array,
|
|
9
8
|
Signature,
|
|
@@ -54,7 +53,7 @@ class Ledger_Transaction(GrapheneUnsigned_Transaction):
|
|
|
54
53
|
dongle = getDongle(True)
|
|
55
54
|
apdu_list = self.build_apdu(path, chain)
|
|
56
55
|
for apdu in apdu_list:
|
|
57
|
-
result = dongle.exchange(
|
|
56
|
+
result = dongle.exchange(bytes(apdu))
|
|
58
57
|
dongle.close()
|
|
59
58
|
sigs = []
|
|
60
59
|
signature = result
|
|
@@ -67,7 +66,7 @@ class Ledger_Transaction(GrapheneUnsigned_Transaction):
|
|
|
67
66
|
|
|
68
67
|
dongle = getDongle(True)
|
|
69
68
|
apdu = self.build_apdu_pubkey(path, request_screen_approval)
|
|
70
|
-
result = dongle.exchange(
|
|
69
|
+
result = dongle.exchange(bytes(apdu))
|
|
71
70
|
dongle.close()
|
|
72
71
|
offset = 1 + result[0]
|
|
73
72
|
address = result[offset + 1 : offset + 1 + result[offset]]
|
nectarbase/memo.py
CHANGED
|
@@ -3,7 +3,6 @@ import hashlib
|
|
|
3
3
|
from binascii import hexlify, unhexlify
|
|
4
4
|
|
|
5
5
|
from nectargraphenebase.base58 import base58decode, base58encode
|
|
6
|
-
from nectargraphenebase.py23 import py23_bytes
|
|
7
6
|
from nectargraphenebase.types import varintdecode
|
|
8
7
|
|
|
9
8
|
try:
|
|
@@ -50,7 +49,7 @@ def init_aes(shared_secret, nonce):
|
|
|
50
49
|
" Shared Secret "
|
|
51
50
|
ss = hashlib.sha512(unhexlify(shared_secret)).digest()
|
|
52
51
|
" Seed "
|
|
53
|
-
seed =
|
|
52
|
+
seed = bytes(str(nonce), "ascii") + hexlify(ss)
|
|
54
53
|
seed_digest = hexlify(hashlib.sha512(seed).digest()).decode("ascii")
|
|
55
54
|
" AES "
|
|
56
55
|
key = unhexlify(seed_digest[0:64])
|
|
@@ -76,7 +75,7 @@ def init_aes_bts(shared_secret, nonce):
|
|
|
76
75
|
return AES.new(key, AES.MODE_CBC, iv)
|
|
77
76
|
|
|
78
77
|
|
|
79
|
-
def
|
|
78
|
+
def init_aes2(shared_secret, nonce):
|
|
80
79
|
"""Initialize AES instance
|
|
81
80
|
:param hex shared_secret: Shared Secret to use as encryption key
|
|
82
81
|
:param int nonce: Random nonce
|
|
@@ -121,7 +120,7 @@ def encode_memo_bts(priv, pub, nonce, message):
|
|
|
121
120
|
shared_secret = get_shared_secret(priv, pub)
|
|
122
121
|
aes = init_aes_bts(shared_secret, nonce)
|
|
123
122
|
" Checksum "
|
|
124
|
-
raw =
|
|
123
|
+
raw = bytes(message, "utf8")
|
|
125
124
|
checksum = hashlib.sha256(raw).digest()
|
|
126
125
|
raw = checksum[0:4] + raw
|
|
127
126
|
" Padding "
|
|
@@ -146,7 +145,7 @@ def decode_memo_bts(priv, pub, nonce, message):
|
|
|
146
145
|
shared_secret = get_shared_secret(priv, pub)
|
|
147
146
|
aes = init_aes_bts(shared_secret, nonce)
|
|
148
147
|
" Encryption "
|
|
149
|
-
raw =
|
|
148
|
+
raw = bytes(message, "ascii")
|
|
150
149
|
cleartext = aes.decrypt(unhexlify(raw))
|
|
151
150
|
" Checksum "
|
|
152
151
|
checksum = cleartext[0:4]
|
|
@@ -170,9 +169,9 @@ def encode_memo(priv, pub, nonce, message, **kwargs):
|
|
|
170
169
|
:rtype: hex
|
|
171
170
|
"""
|
|
172
171
|
shared_secret = get_shared_secret(priv, pub)
|
|
173
|
-
aes, check =
|
|
172
|
+
aes, check = init_aes2(shared_secret, nonce)
|
|
174
173
|
" Padding "
|
|
175
|
-
raw =
|
|
174
|
+
raw = bytes(message, "utf8")
|
|
176
175
|
raw = _pad(raw, 16)
|
|
177
176
|
" Encryption "
|
|
178
177
|
cipher = hexlify(aes.encrypt(raw)).decode("ascii")
|
|
@@ -186,7 +185,7 @@ def encode_memo(priv, pub, nonce, message, **kwargs):
|
|
|
186
185
|
"prefix": prefix,
|
|
187
186
|
}
|
|
188
187
|
tx = Memo(**s)
|
|
189
|
-
return "#" + base58encode(hexlify(
|
|
188
|
+
return "#" + base58encode(hexlify(bytes(tx)).decode("ascii"))
|
|
190
189
|
|
|
191
190
|
|
|
192
191
|
def extract_memo_data(message):
|
|
@@ -225,7 +224,7 @@ def decode_memo(priv, message):
|
|
|
225
224
|
raise ValueError("Incorrect PrivateKey")
|
|
226
225
|
|
|
227
226
|
# Init encryption
|
|
228
|
-
aes, checksum =
|
|
227
|
+
aes, checksum = init_aes2(shared_secret, nonce)
|
|
229
228
|
# Check
|
|
230
229
|
if not check == checksum:
|
|
231
230
|
raise AssertionError("Checksum failure")
|
|
@@ -234,7 +233,7 @@ def decode_memo(priv, message):
|
|
|
234
233
|
numBytes = 16 - len(cipher) % 16
|
|
235
234
|
n = 16 - numBytes
|
|
236
235
|
message = cipher[n:]
|
|
237
|
-
message = aes.decrypt(unhexlify(
|
|
236
|
+
message = aes.decrypt(unhexlify(bytes(message, "ascii")))
|
|
238
237
|
message = _unpad(message, 16)
|
|
239
238
|
n = varintdecode(message)
|
|
240
239
|
if (len(message) - n) > 0 and (len(message) - n) < 8:
|
nectarbase/objects.py
CHANGED
|
@@ -8,7 +8,6 @@ from nectargraphenebase.account import PublicKey
|
|
|
8
8
|
from nectargraphenebase.chains import known_chains
|
|
9
9
|
from nectargraphenebase.objects import GrapheneObject, isArgsThisClass
|
|
10
10
|
from nectargraphenebase.objects import Operation as GPHOperation
|
|
11
|
-
from nectargraphenebase.py23 import py23_bytes, string_types
|
|
12
11
|
from nectargraphenebase.types import (
|
|
13
12
|
Array,
|
|
14
13
|
Bytes,
|
|
@@ -38,7 +37,7 @@ def value_to_decimal(value, decimal_places):
|
|
|
38
37
|
class Amount(object):
|
|
39
38
|
def __init__(self, d, prefix=default_prefix, json_str=False):
|
|
40
39
|
self.json_str = json_str
|
|
41
|
-
if isinstance(d,
|
|
40
|
+
if isinstance(d, str):
|
|
42
41
|
self.amount, self.symbol = d.strip().split(" ")
|
|
43
42
|
self.precision = None
|
|
44
43
|
for c in known_chains:
|
|
@@ -113,7 +112,7 @@ class Amount(object):
|
|
|
113
112
|
return (
|
|
114
113
|
struct.pack("<q", int(self.amount))
|
|
115
114
|
+ struct.pack("<b", self.precision)
|
|
116
|
-
+
|
|
115
|
+
+ bytes(symbol, "ascii")
|
|
117
116
|
)
|
|
118
117
|
|
|
119
118
|
def __str__(self):
|
|
@@ -150,7 +149,7 @@ class Operation(GPHOperation):
|
|
|
150
149
|
# return json.loads(str(json.dumps([self.name, self.op.toJson()])))
|
|
151
150
|
|
|
152
151
|
def __bytes__(self):
|
|
153
|
-
return
|
|
152
|
+
return bytes(Id(self.opId)) + bytes(self.op)
|
|
154
153
|
|
|
155
154
|
def __str__(self):
|
|
156
155
|
if self.appbase:
|
|
@@ -364,7 +363,7 @@ class CommentOptionExtensions(Static_variant):
|
|
|
364
363
|
"""
|
|
365
364
|
|
|
366
365
|
def __init__(self, o):
|
|
367
|
-
if
|
|
366
|
+
if isinstance(o, dict) and "type" in o and "value" in o:
|
|
368
367
|
if o["type"] == "comment_payout_beneficiaries":
|
|
369
368
|
type_id = 0
|
|
370
369
|
else:
|
nectarbase/operations.py
CHANGED
|
@@ -5,7 +5,6 @@ from binascii import hexlify
|
|
|
5
5
|
from collections import OrderedDict
|
|
6
6
|
|
|
7
7
|
from nectargraphenebase.account import PublicKey
|
|
8
|
-
from nectargraphenebase.py23 import PY2, PY3, string_types
|
|
9
8
|
from nectargraphenebase.types import (
|
|
10
9
|
Array,
|
|
11
10
|
Bool,
|
|
@@ -58,7 +57,7 @@ class Transfer(GrapheneObject):
|
|
|
58
57
|
if isinstance(kwargs["memo"], dict):
|
|
59
58
|
kwargs["memo"]["prefix"] = prefix
|
|
60
59
|
memo = Optional(Memo(**kwargs["memo"]))
|
|
61
|
-
elif isinstance(kwargs["memo"],
|
|
60
|
+
elif isinstance(kwargs["memo"], str):
|
|
62
61
|
memo = String(kwargs["memo"])
|
|
63
62
|
else:
|
|
64
63
|
memo = Optional(Memo(kwargs["memo"]))
|
|
@@ -90,7 +89,7 @@ class Recurring_transfer(GrapheneObject):
|
|
|
90
89
|
if isinstance(kwargs["memo"], dict):
|
|
91
90
|
kwargs["memo"]["prefix"] = prefix
|
|
92
91
|
memo = Optional(Memo(**kwargs["memo"]))
|
|
93
|
-
elif isinstance(kwargs["memo"],
|
|
92
|
+
elif isinstance(kwargs["memo"], str):
|
|
94
93
|
memo = String(kwargs["memo"])
|
|
95
94
|
else:
|
|
96
95
|
memo = Optional(Memo(kwargs["memo"]))
|
|
@@ -539,10 +538,8 @@ class Witness_set_properties(GrapheneObject):
|
|
|
539
538
|
for k in kwargs["props"]:
|
|
540
539
|
if k[0] in ["key", "new_signing_key"]:
|
|
541
540
|
continue
|
|
542
|
-
if isinstance(k[1], str)
|
|
541
|
+
if isinstance(k[1], str):
|
|
543
542
|
is_hex = re.fullmatch(r"[0-9a-fA-F]+", k[1] or "") is not None
|
|
544
|
-
elif isinstance(k[1], str) and PY2:
|
|
545
|
-
is_hex = re.match(r"[0-9a-fA-F]+", k[1] or "") is not None
|
|
546
543
|
else:
|
|
547
544
|
is_hex = False
|
|
548
545
|
if isinstance(k[1], int) and k[0] in [
|
|
@@ -991,7 +988,6 @@ class Transfer_from_savings(GrapheneObject):
|
|
|
991
988
|
json_str = kwargs.get("json_str", False)
|
|
992
989
|
if "memo" not in kwargs:
|
|
993
990
|
kwargs["memo"] = ""
|
|
994
|
-
|
|
995
991
|
super(Transfer_from_savings, self).__init__(
|
|
996
992
|
OrderedDict(
|
|
997
993
|
[
|
nectarbase/version.py
CHANGED