Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting & Formatting updates #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ __pycache__/
electrum/
secp256k1/
venv/
wallet_service_db
Electrum-**
config.ini
wallet_service_db
36 changes: 36 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"pylint.args": [
"--disable=C0103,C0114,C0115,C0116,C0121,C0209,C0410,C0411,W0201,W0611,W0612,W0613,W0621,W0707,W0718,W0719,W1202,W1514,E1101",
"--indent-string=' '",
"--max-line-length=120",
],
"yapf.args": [
"--style",
"{based_on_style: pep8, indent_width: 2, column_limit: 120}"
],
"[python]": {
"editor.formatOnSaveMode": "file",
"editor.formatOnSave": true,
"editor.defaultFormatter": "eeyore.yapf",
"editor.formatOnType": false
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/__pycache__": true,
"**/env": true,
"Electrum-**": true,
"**/__init__.py": true,
"venv": true,
"wallets": true,
"config.ini": true,
"config.ini.sample": true,
"wallet_service_supervisor.conf": true,
"debug.log*": true,
"wallet_service_db": true,
}
}
29 changes: 14 additions & 15 deletions db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,39 @@
import uuid
import cryptocode


class DbManager:

def __init__(self, echo_mode=False):
Base = declarative_base()
engine = create_engine('sqlite:///wallet_service_db', echo=echo_mode)
Base.metadata.bind = engine
self.session = sessionmaker(bind=engine)()

def __del__(self):
self.session.close()

def __exit__(self, *err):
pass

def __enter__(self):
return self

def close_session(self):
self.session.close()
self.session.close()

def insert_transaction(self, address, amount, wallet_id, wallet_password):
# Only sent transactions have txid and fee
sr_id = str(uuid.uuid4().hex)
obj = Transactions(
sr_id = sr_id,
txid = None,
address = address,
amount = amount,
wallet_id = wallet_id,
fee = None,
sr_timestamp = int(time.time()),
tx_timestamp = None,
wallet_password = cryptocode.encrypt(wallet_password, sr_id)
)
obj = Transactions(sr_id=sr_id,
txid=None,
address=address,
amount=amount,
wallet_id=wallet_id,
fee=None,
sr_timestamp=int(time.time()),
tx_timestamp=None,
wallet_password=cryptocode.encrypt(wallet_password, sr_id))
self.session.add(obj)
self.session.commit()
return obj
Expand Down
24 changes: 13 additions & 11 deletions db_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@

Base = declarative_base()


class Transactions(Base):
__tablename__ = 'transactions'
sr_id = Column(String(250), primary_key = True)
txid = Column(String(250))
address = Column(String(250), primary_key = True)
amount = Column(Integer)
wallet_id = Column(Integer)
fee = Column(Integer)
sr_timestamp = Column(BigInteger)
tx_timestamp = Column(BigInteger)
wallet_password = Column(String(2000))
__tablename__ = 'transactions'
sr_id = Column(String(250), primary_key=True)
txid = Column(String(250))
address = Column(String(250), primary_key=True)
amount = Column(Integer)
wallet_id = Column(Integer)
fee = Column(Integer)
sr_timestamp = Column(BigInteger)
tx_timestamp = Column(BigInteger)
wallet_password = Column(String(2000))


Base.metadata.create_all(engine)
Base.metadata.create_all(engine)
Loading