Skip to content

Commit ca88fa1

Browse files
committed
Update for ripemd160 native
1 parent 2a8f7c1 commit ca88fa1

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

.DS_Store

-6 KB
Binary file not shown.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,7 @@ cython_debug/
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162162
#.idea/
163+
164+
# Eclipse
165+
.project
166+
.pydevproject

SentinelMultiPay.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
import bech32
1717
from mospy import Transaction
1818
from grpc import RpcError
19+
from Crypto.Hash import RIPEMD160
1920

2021
from datetime import datetime
2122

2223
MNAPI = "https://api.sentinel.mathnodes.com"
2324
NODEAPI = "/sentinel/nodes/%s"
2425
GRPC = scrtxxs.GRPC
2526
SSL = True
26-
VERSION = 20240817.1914
27+
VERSION = 20240818.0304
2728
SATOSHI = 1000000
2829

2930
class MultiPay():
@@ -36,7 +37,7 @@ def __init__(self, keyring_passphrase, wallet_name, seed_phrase = None):
3637
privkey_obj = ecdsa.SigningKey.from_string(bip44_def_ctx.PrivateKey().Raw().ToBytes(), curve=ecdsa.SECP256k1)
3738
pubkey = privkey_obj.get_verifying_key()
3839
s = hashlib.new("sha256", pubkey.to_string("compressed")).digest()
39-
r = hashlib.new("ripemd160", s).digest()
40+
r = self.ripemd160(s)
4041
five_bit_r = bech32.convertbits(r, 8, 5)
4142
account_address = bech32.bech32_encode("sent", five_bit_r)
4243
print(account_address)
@@ -55,6 +56,18 @@ def __init__(self, keyring_passphrase, wallet_name, seed_phrase = None):
5556

5657
now = datetime.now()
5758
self.logfile.write(f"\n---------------------------{now}---------------------------\n")
59+
60+
def ripemd160(self, contents: bytes) -> bytes:
61+
"""
62+
Get ripemd160 hash using PyCryptodome.
63+
64+
:param contents: bytes contents.
65+
66+
:return: bytes ripemd160 hash.
67+
"""
68+
h = RIPEMD160.new()
69+
h.update(contents)
70+
return h.digest()
5871

5972
def __keyring(self, keyring_passphrase: str):
6073
if not path.isdir(scrtxxs.KeyringDIR):
@@ -172,7 +185,7 @@ def SendDVPNs(self, addr_amts, wallet_balance: int):
172185

173186
print("The following addresses will receive these repsective amounts: ")
174187
print(SendDict)
175-
answer = input("Would you iike to continue (Y/n): ")
188+
answer = input("Would you like to continue (Y/n): ")
176189
if answer.upper() == "Y":
177190
if mp.SendDVPNs(SendDict, int(wallet_balance * SATOSHI)):
178191
print("Transaction completed successfully. Please check the log file")

0 commit comments

Comments
 (0)