diff --git a/lib/getblocks.py b/lib/getblocks.py new file mode 100644 index 0000000..56ee2b1 --- /dev/null +++ b/lib/getblocks.py @@ -0,0 +1,34 @@ +import requests +import json +import time +import datetime +import ctypes + + +pyarr = [1] +arr = (ctypes.c_int * len(pyarr))(*pyarr) +# Set server for RPC call to bitmonerod +default_URL = 'http://localhost:18081/gettransactions' +# Headers, because headers +headers = {'content-type': 'application/json'} +# Data to give to bitmonerod to check last block info +payload = json.dumps({'tx ids': ''}) + + +def GetBlocks(serverURL=default_URL): + """Try and get last block info and return formatted text""" + # print('Attempting {0} RPC call'.format(CheckLastBlock.__name__)) + try: + resp = requests.get(serverURL, headers=headers, data=payload) + # output = json.loads(resp.text) + print(resp) + + + except: + #Return out of sync if bitmonerod is not ready + message = "Can't connect to bitmonerod" + return message, message, message, message + + +if __name__ == "__main__": + GetBlocks() \ No newline at end of file diff --git a/lib/gettransfers.py b/lib/gettransfers.py new file mode 100644 index 0000000..b2a94f2 --- /dev/null +++ b/lib/gettransfers.py @@ -0,0 +1,38 @@ +import requests +import json +import time + +serverURL = 'http://localhost:19091/json_rpc' + +headers = {'content-type': 'application/json'} + +payload = json.dumps({ + "jsonrpc": "2.0", + "method": "incoming_transfers", + "params": {"transfer_type": "all"} +}) + +# payload = json.dumps({ +# "jsonrpc": "2.0", +# "method": "incoming_transfers", +# "params": {"transfer_type": "all"} +# }) + + +def getTransfers(): + unspent_txs, spent_txs = [], [] + try: + resp = requests.get(serverURL, headers=headers, data=payload) + output = json.loads(resp.text) + for i in output[u'result'][u'transfers']: + if i[u'spent'] == False: + unspent_txs.append([i[u'tx_hash'].strip('<>'), int(i[u'amount'])/1e12, i[u'spent']]) + elif i[u'spent'] == True: + spent_txs.append([i[u'tx_hash'].strip('<>'), int(i[u'amount'])/1e12, i[u'spent']]) + except: + pass + return unspent_txs, spent_txs + + +if __name__ == '__main__': + getTransfers() \ No newline at end of file diff --git a/lib/popupTest.py b/lib/popupTest.py new file mode 100644 index 0000000..a4dc5bd --- /dev/null +++ b/lib/popupTest.py @@ -0,0 +1,64 @@ +from kivy._event import partial +from kivy.app import App +from kivy.core.clipboard import Clipboard +from kivy.lang import Builder +from kivy.uix.boxlayout import BoxLayout +from kivy.uix.button import Button + + + +Builder.load_string(""" + + BoxLayout: + padding: 30, 30, 30, 30 + orientation: "vertical" + Label: + size_hint: 1, 0.2 + text: "Double click buttons to copy tx id" + ScrollView: + id: tx_scroller + size_hint: 1, 0.8 + GridLayout: + cols: 1 + spacing: 7 + size_hint_y: None + id: tx_list +""") + +tx_list = [ + ['asdf', 1.234, False], + ['fghj', 2.234, False], + ['xvbb', 3.234, False], + ['wetw', 4.234, False], + ['hjkl', 5.234, False], + ['wret', 6.234, False], + ['bvnm', 7.234, False], + ['zzzz', 8.234, False] + ] + + +class RootWidget(BoxLayout): + """Root Kivy accordion widget class""" + tx_dict = {} + def __init__(self, **kwargs): + super(RootWidget, self).__init__(**kwargs) + for idx, val in enumerate(tx_list): + self.tx_dict[idx] = Button(text="tx_id: {0} | amount: {1:.4f}".format(val[0], val[1]), + size_hint_y=None, height=15, font_size=9) + self.tx_dict[idx].bind(on_press=self._create_button_callback(val[0])) + self.ids.tx_list.add_widget(self.tx_dict[idx]) + + def _create_button_callback(self, val): + def callback(button): + Clipboard.put(val) + return callback + +class lightWalletApp(App): + def build(self): + root = RootWidget() + return root + + +if __name__ == '__main__': + lightWalletApp().run() +