Skip to content

Commit

Permalink
Update for ripemd160 native
Browse files Browse the repository at this point in the history
  • Loading branch information
freQniK committed Aug 18, 2024
1 parent 2a8f7c1 commit ca88fa1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Binary file removed .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Eclipse
.project
.pydevproject
19 changes: 16 additions & 3 deletions SentinelMultiPay.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
import bech32
from mospy import Transaction
from grpc import RpcError
from Crypto.Hash import RIPEMD160

from datetime import datetime

MNAPI = "https://api.sentinel.mathnodes.com"
NODEAPI = "/sentinel/nodes/%s"
GRPC = scrtxxs.GRPC
SSL = True
VERSION = 20240817.1914
VERSION = 20240818.0304
SATOSHI = 1000000

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

now = datetime.now()
self.logfile.write(f"\n---------------------------{now}---------------------------\n")

def ripemd160(self, contents: bytes) -> bytes:
"""
Get ripemd160 hash using PyCryptodome.
:param contents: bytes contents.
:return: bytes ripemd160 hash.
"""
h = RIPEMD160.new()
h.update(contents)
return h.digest()

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

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

0 comments on commit ca88fa1

Please sign in to comment.