Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
THONG NGO committed Sep 1, 2021
0 parents commit 793a8b9
Show file tree
Hide file tree
Showing 56 changed files with 11,018 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
*.swp
2 changes: 2 additions & 0 deletions Adding Bitcoin Vietnam and VBTC exchange #2166
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# bitcoinwallet
Adding Bitcoin Vietnam and VBTC exchange #2166
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
This code is public domain. Everyone has the right to do whatever they want
with it for any purpose.

In case your jurisdiction does not consider the above disclaimer valid or
enforceable, here's an MIT license for you:

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include cryptos/english.txt
include LICENSE
include README.md
633 changes: 633 additions & 0 deletions THONG-NGO

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions cryptos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from .blocks import *
from .composite import *
from .deterministic import *
from .main import *
from .mnemonic import *
from .py2specials import *
from .py3specials import *
from .stealth import *
from .transaction import *
from .coins import *
from .keystore import *
from .wallet import *
50 changes: 50 additions & 0 deletions cryptos/blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from .main import *


def serialize_header(inp):
o = encode(inp['version'], 256, 4)[::-1] + \
inp['prevhash'].decode('hex')[::-1] + \
inp['merkle_root'].decode('hex')[::-1] + \
encode(inp['timestamp'], 256, 4)[::-1] + \
encode(inp['bits'], 256, 4)[::-1] + \
encode(inp['nonce'], 256, 4)[::-1]
h = bin_sha256(bin_sha256(o))[::-1].encode('hex')
assert h == inp['hash'], (sha256(o), inp['hash'])
return o.encode('hex')


def deserialize_header(inp):
inp = inp.decode('hex')
return {
"version": decode(inp[:4][::-1], 256),
"prevhash": inp[4:36][::-1].encode('hex'),
"merkle_root": inp[36:68][::-1].encode('hex'),
"timestamp": decode(inp[68:72][::-1], 256),
"bits": decode(inp[72:76][::-1], 256),
"nonce": decode(inp[76:80][::-1], 256),
"hash": bin_sha256(bin_sha256(inp))[::-1].encode('hex')
}


def mk_merkle_proof(header, hashes, index):
nodes = [safe_from_hex(h)[::-1] for h in hashes]
if len(nodes) % 2 and len(nodes) > 2:
nodes.append(nodes[-1])
layers = [nodes]
while len(nodes) > 1:
newnodes = []
for i in range(0, len(nodes) - 1, 2):
newnodes.append(bin_sha256(bin_sha256(nodes[i] + nodes[i+1])))
if len(newnodes) % 2 and len(newnodes) > 2:
newnodes.append(newnodes[-1])
nodes = newnodes
layers.append(nodes)
# Sanity check, make sure merkle root is valid
assert bytes_to_hex_string(nodes[0][::-1]) == header['merkle_root']
merkle_siblings = \
[layers[i][(index >> i) ^ 1] for i in range(len(layers)-1)]
return {
"hash": hashes[index],
"siblings": [bytes_to_hex_string(x[::-1]) for x in merkle_siblings],
"header": header
}
6 changes: 6 additions & 0 deletions cryptos/coins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .bitcoin import *
from .bitcoin_cash import *
from .bitcoin_gold import *
from .dash import *
from .dogecoin import *
from .litecoin import *
Loading

0 comments on commit 793a8b9

Please sign in to comment.