mirror of
https://git.wownero.com/wownero/wownero-funding-system.git
synced 2024-08-15 00:53:45 +00:00
aeonfunding update for wownero
a lot more generic; a lot more configurable; UI goodness with accounting; wallet account support for ezmode
This commit is contained in:
parent
f473a4234e
commit
955de2544e
19 changed files with 361 additions and 173 deletions
|
@ -1,10 +1,12 @@
|
|||
import settings
|
||||
import requests
|
||||
from requests.auth import HTTPDigestAuth
|
||||
|
||||
|
||||
class WowneroDaemon:
|
||||
class Daemon:
|
||||
def __init__(self):
|
||||
self.url = settings.RPC_LOCATION
|
||||
self.username = settings.RPC_USERNAME
|
||||
self.password = settings.RPC_PASSWORD
|
||||
self.headers = {"User-Agent": "Mozilla"}
|
||||
|
||||
def create_address(self, label_name):
|
||||
|
@ -16,37 +18,65 @@ class WowneroDaemon:
|
|||
}
|
||||
return self._make_request(data)
|
||||
|
||||
def get_address(self, index):
|
||||
def create_account(self, pid):
|
||||
data = {
|
||||
'method': 'get_address',
|
||||
'params': {'address_index': [index], 'account_index': 0},
|
||||
'method': 'create_account',
|
||||
'params': {'label': '%s' % pid},
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
return self._make_request(data)
|
||||
|
||||
def get_address(self, index, proposal_id):
|
||||
data = {
|
||||
'method': 'getaddress',
|
||||
'params': {'account_index': proposal_id, 'address_index': '[0]'},
|
||||
'jsonrpc': '2.0',
|
||||
'id': '0'
|
||||
}
|
||||
try:
|
||||
result = self._make_request(data)
|
||||
return next(z for z in result['result']['addresses'] if z['address_index'] == index)
|
||||
return result['result']
|
||||
except:
|
||||
return
|
||||
|
||||
def get_transfers_in(self, index):
|
||||
def get_transfers_in(self, index, proposal_id):
|
||||
data = {
|
||||
"method":"get_transfers",
|
||||
"params": {"pool": True, "in": True, "account_index": 0, "subaddr_indices": [index]},
|
||||
"params": {"pool": True, "in": True, "account_index": proposal_id},
|
||||
"jsonrpc": "2.0",
|
||||
"id": "0",
|
||||
}
|
||||
data = self._make_request(data)
|
||||
data = data['result'].get('in', [])
|
||||
for d in data:
|
||||
d['amount_human'] = float(d['amount'])/1e11
|
||||
|
||||
d['amount_human'] = float(d['amount'])/1e12
|
||||
return {
|
||||
'sum': sum([float(z['amount'])/1e11 for z in data]),
|
||||
'sum': sum([float(z['amount'])/1e12 for z in data]),
|
||||
'txs': data
|
||||
}
|
||||
|
||||
def get_transfers_out(self, index, proposal_id):
|
||||
data = {
|
||||
"method":"get_transfers",
|
||||
"params": {"pool": True, "out": True, "account_index": proposal_id},
|
||||
"jsonrpc": "2.0",
|
||||
"id": "0",
|
||||
}
|
||||
data = self._make_request(data)
|
||||
data = data['result'].get('out', [])
|
||||
for d in data:
|
||||
d['amount_human'] = float(d['amount'])/1e12
|
||||
return {
|
||||
'sum': sum([float(z['amount'])/1e12 for z in data]),
|
||||
'txs': data
|
||||
}
|
||||
|
||||
def _make_request(self, data):
|
||||
r = requests.post(self.url, json=data, headers=self.headers)
|
||||
if self.username:
|
||||
if self.password:
|
||||
r = requests.post(self.url, auth=HTTPDigestAuth(settings.RPC_USERNAME, settings.RPC_PASSWORD), json=data, headers=self.headers)
|
||||
else:
|
||||
r = requests.post(self.url, json=data, headers=self.headers)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
return r.json()
|
Loading…
Add table
Add a link
Reference in a new issue