Skip to content

Commit

Permalink
Bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniGlome authored Sep 26, 2021
1 parent c0e833f commit a27a08f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sign_Transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def to_DER(r, s): # Signature to DER format

return res.hex()

def hexify(n):
n = hex(n)[2:]
if len(n)%2 != 0:
n = "0"+n
return n


def Sign_Transaction(seedHex, TransactionHex):
Expand All @@ -92,7 +97,7 @@ def Sign_Transaction(seedHex, TransactionHex):
r = kpX % n
s = pow(k, -1, n) * (r * int(seedHex, 16)+int(s256.hex(), 16))
s = s % n
signature = to_DER(hex(r)[2:].zfill(64), hex(s)[2:].zfill(64))
signature = to_DER(hexify(r), hexify(s))
signed_transaction = TransactionHex[:-2] + hex(len(bytearray.fromhex(signature)))[2:] + signature
return signed_transaction

Expand Down

0 comments on commit a27a08f

Please sign in to comment.