class BitPort(object): def __init__(self, config=None): self.conf = ConfigBasic() # pass self.rpc = AuthServiceProxy("http://{}:{}@{}".format( self.conf.rpc_user, self.conf.rpc_password, self.conf.rpc_host)) def get_amount_by_addr(self, addr): return self.rpc.getreceivedbyaddress(addr) def get_unconfirm(self, addr): return self.rpc.getunconfirmedbalance(addr) def get_unspent(self, addr): """ @param addr: A array with address, ["0xxxxxx", "0x122222"] """ return self.rpc.listunspent(0, 999999, addr) def sign_rawtransaction(self, addr): fee_obj = self.rpc.estimatesmartfee(6) fee = fee_obj.get("feerate") def sendrawtransaction(self, address, pubkey): pass
def submit_raw(rpc_user, rpc_password, rpc_host, send_addr=None, recv_addr=None, send_amount=None): rpc_connection = AuthServiceProxy("http://{}:{}@{}".format( rpc_user, rpc_password, rpc_host)) # ... #rpc_connection.walletpassphrase("openos", 10) # validate address ret = rpc_connection.validateaddress(recv_addr) if recv_addr else {} # ... first_unspent = rpc_connection.listunspent()[0] print(first_unspent) address = first_unspent.get("address") scriptPubKey = first_unspent.get("scriptPubKey") redeemScript = first_unspent.get("redeemScript") txid = first_unspent.get("txid") vout = first_unspent.get("vout") #first_unspent_amount = Decimal(first_unspent.get("amount")) #username = rpc_connection.getaccountaddress(send_addr) #print(username) username = '******' first_unspent_amount = Decimal(rpc_connection.getbalance(username)) raw_change_address = rpc_connection.getrawchangeaddress() new_bitcoin_address = recv_addr if recv_addr else rpc_connection.getnewaddress( ) print("raw_change_address [{}]".format(raw_change_address)) fee_obj = rpc_connection.estimatesmartfee(6) fee = fee_obj.get("feerate") # check if send_amount: print(first_unspent_amount, fee, send_amount) change_amount = first_unspent_amount - fee - send_amount else: send_amount = first_unspent_amount / 2 change_amount = first_unspent_amount / 2 - fee if change_amount < 0.00001: print(change_amount) raise Exception("Insufficient funds") change_amount_string = "%.8f" % change_amount send_amount_string = "%0.8f" % send_amount data = "@landpack" if len(data) > 75: print("Data length is {}".format(len(data))) raise Exception("Too much data, use OP_PUSHDATA1 instead") hex_format_data = binascii.hexlify(data) hexstring = rpc_connection.createrawtransaction( [{ "txid": txid, "vout": vout }], { "data": hex_format_data, new_bitcoin_address: send_amount_string, raw_change_address: change_amount_string }) privkey = rpc_connection.dumpprivkey(address) sign_raw_transaction = rpc_connection.signrawtransaction( hexstring, [{ "txid": txid, "vout": vout, "redeemScript": redeemScript, "scriptPubKey": scriptPubKey, "amount": first_unspent_amount }], [privkey]) raw_hash = sign_raw_transaction.get("hex") ret = rpc_connection.sendrawtransaction(raw_hash) return ret
first_unspent_amount = Decimal(first_unspent.get("amount")) print(first_unspent_amount) addr1 = rpc_connection.getnewaddress() addr2 = rpc_connectio.getnewaddress() addr3 = rpc_connectio.getnewaddress() addr4 = rpc_connectio.getnewaddress( ) # destination address which we will send to raw_change_address = rpc_connection.getrawchangeaddress() new_bitcoin_address = rpc_connection.getnewaddress() print(raw_change_address) print(new_bitcoin_address) fee_obj = rpc_connection.estimatesmartfee(6) fee = fee_obj.get("feerate") send_amount = first_unspent_amount / 2 change_amount = first_unspent_amount / 2 - fee if change_amount < 0.00001: print(change_amount) raise Exception("Insufficient funds") change_amount_string = "%.8f" % change_amount send_amount_string = "%0.8f" % send_amount data = "@rusticbison" if len(data) > 75:
class Wallet: def __init__(self, network: str, datadir: str): global network_port_map_g, ltc_network_port_map_g, transfer_info_map_g self.rpc_user = input('RPC Username: '******'RPC Password: '******'Username: '******'Select Crypto(0 => Bitcoin or 1 => Litecoin): '))] self.rpc_port = network_port_map_g[self.crypto][network] self.rpc_connection = AuthServiceProxy( "http://%s:%[email protected]:%d" % (self.rpc_user, self.rpc_password, self.rpc_port), timeout=10000) self.network = network self.transfer_info_filepath = os.path.join( datadir, '%s.%s.%s.json' % (transfer_info_map_g[network], self.crypto, user)) self.user = user def isAddressUnused(self, address: str): if self.crypto == 'bitcoin': res = requests.get('https://blockchain.info/rawaddr/' + address) jsonobj = json.loads(res.text) return (jsonobj['total_received'] == 0) if self.crypto == 'litecoin': res = requests.get('https://chain.so/api/v2/address/LTC/' + address) jsonobj = json.loads(res.text) return (jsonobj['data']['total_txs'] == 0) def setUnusedAddresses(self): self.unused_list = [ address for address in self.jsonobj['Addresses'] if self.isAddressUnused(address) == True ] def setUnusedAddressesTest(self): unspent_list = self.rpc_connection.listunspent() if len(unspent_list) > 0: inuse_addresses = [unspent['address'] for unspent in unspent_list] index = 0 for inuse_address in inuse_addresses: if inuse_address in self.jsonobj['Addresses']: new_index = self.jsonobj['Addresses'].index(inuse_address) index = new_index if new_index > index else index self.unused_list = copy(self.jsonobj['Addresses'][index + 1:]) else: self.unused_list = copy(self.jsonobj['Addresses']) # print('unused list = %s' % self.unused_list) def getNextAddresses(self): if network == 'regtest': self.setUnusedAddressesTest() else: self.setUnusedAddresses() count = int(input('Enter Number of Unused Addresses: ')) addresses = self.unused_list[0:count] return addresses # def getTargetAddresses(self): # if network == 'regtest': # self.setUnusedAddressesTest() # else: # self.setUnusedAddresses() # # out_count = int(input('Enter Number of Target Addresses: ')) # # tx_out = [] # # unused_addresses = copy(self.unused_list) # # for i in range(out_count): # address_value = {} # choice = (input('Scan QR code [Y/n]: ') or 'Y').lower() # if choice == 'y': # qrcode = qrutils.scanQRCode() # if ':' in qrcode and qrcode.split(':')[0] != self.crypto: # print('Address belong to different cryptocurrency i.e. %s' % qrcode.split(':')[0]) # exit() # address = qrcode.split(':')[1].split('?')[0] if ':' in qrcode else qrcode.split('?')[0] # value = float(qrcode.split('?')[1].split('=')[1]) if '?' in qrcode else float(input('Enter Btc/Ltc: ')) # elif choice == 'n': # address = input('Enter Target Address: ') # value = float(input('Enter Bitcoins: ')) # else: # print('Invalid entry') # exit() # address_value[address] = value # # if address in unused_addresses: # unused_addresses.remove(address) # # tx_out.append(address_value) # # if len(set(tx_out)) != out_count: # print('Address repetition is not allowed in target') # exit() # # change_address = unused_addresses[0] # print('change address: %s' % change_address) # return tx_out, change_address def getTargetAddresses(self): if network == 'regtest': self.setUnusedAddressesTest() else: self.setUnusedAddresses() out_count = int(input('Enter Number of Target Addresses: ')) tx_out = [] unused_addresses = copy(self.unused_list) tx_out = {} for i in range(out_count): choice = (input('Scan QR code [Y/n]: ') or 'Y').lower() if choice == 'y': qrcode = qrutils.scanQRCode() if ':' in qrcode and qrcode.split(':')[0] != self.crypto: print( 'Address belong to different cryptocurrency i.e. %s' % qrcode.split(':')[0]) exit() address = qrcode.split(':')[1].split( '?')[0] if ':' in qrcode else qrcode.split('?')[0] value = float(qrcode.split('?')[1].split('=') [1]) if '?' in qrcode else float( input('Enter Btc/Ltc: ')) elif choice == 'n': address = input('Enter Target Address: ') value = float(input('Enter Bitcoins: ')) else: print('Invalid entry') exit() tx_out[address] = value if address in unused_addresses: unused_addresses.remove(address) if len(tx_out) != out_count: print('Address repetition is not allowed in target') exit() change_address = unused_addresses[0] print('change address: %s' % change_address) return tx_out, change_address def getSourceTargetAddresses(self): if network == 'regtest': self.setUnusedAddressesTest() else: self.setUnusedAddresses() out_count = int(input('Enter Number of Input Addresses: ')) input_addresses = [] for i in range(out_count): address = input('Enter Input Address: ') input_addresses.append(address) out_count = int(input('Enter Number of Target Addresses: ')) out_addresses = [] for i in range(out_count): choice = (input('Scan QR code [Y/n]: ') or 'Y').lower() if choice == 'y': qrcode = qrutils.scanQRCode() if ':' in qrcode and qrcode.split(':')[0] != self.crypto: print( 'Address belong to different cryptocurrency i.e. %s' % qrcode.split(':')[0]) exit() if '?' in qrcode: print( 'QR code should not contain amount. Use option "Create Raw Transaction" instead.' ) exit() address = qrcode.split(':')[1] if ':' in qrcode else qrcode elif choice == 'n': address = input('Enter Target Address: ') else: print('Invalid entry') exit() out_addresses.append(address) if len(set(out_addresses)) != out_count: print('Address repetition is not allowed in target') exit() # print('out_addresses = %s' % out_addresses) return input_addresses, out_addresses def validateAddresses(self): address_valid_map = {} for address in self.jsonobj['Addresses']: address_valid_map[address] = self.rpc_connection.validateaddress( address)['isvalid'] return address_valid_map def setNewAddresses(self, addresses: list): label = self.user label_list = self.rpc_connection.listlabels() existing_addresses = [] if label in label_list: existing_addresses = self.rpc_connection.getaddressesbylabel(label) new_addresses = set(addresses) - set(existing_addresses) # print('new_addresses = %s' % new_addresses) return new_addresses def registerAddresses(self, addresses: list): new_addresses = self.setNewAddresses(addresses) s = [] for address in new_addresses: i = { 'scriptPubKey': { 'address': address }, 'timestamp': 0, 'label': self.user, 'watchonly': True } s.append(i) options = {'rescan': False} if len(s) > 0: self.rpc_connection.importmulti(s, options) return new_addresses def createRawTxn(self, fee_rate): # print('transfer_info_filepath = %s' % self.transfer_info_filepath) sys.stdout.flush() self.registerAddresses(self.jsonobj['Addresses']) raw_txn = create_raw_txn.RawTxn(self.rpc_user, self.rpc_password, self.rpc_port, self.transfer_info_filepath, self.user) txout, change_address = self.getTargetAddresses() self.jsonobj = raw_txn.getRawTxnFromOuts(txout, change_address, fee_rate, self.jsonobj) def createRawTxnToDivideFunds(self, fee_rate): # print('transfer_info_filepath = %s' % self.transfer_info_filepath) sys.stdout.flush() self.registerAddresses(self.jsonobj['Addresses']) raw_txn = create_raw_txn.RawTxn(self.rpc_user, self.rpc_password, self.rpc_port, self.transfer_info_filepath, self.user) input_addresses, out_addresses = self.getSourceTargetAddresses() self.jsonobj = raw_txn.getRawTxnToDivideFunds(input_addresses, out_addresses, fee_rate, self.jsonobj) def publishSignedTxn(self): return self.rpc_connection.sendrawtransaction( self.jsonobj['Signed Txn']) def getFeeRate(self, conf_target_block: float): return self.rpc_connection.estimatesmartfee( conf_target_block)['feerate'] def decodeSignedTransaction(self): return self.rpc_connection.decoderawtransaction( self.jsonobj['Signed Txn'])
while True: bitcoin_req = "http://" + sys.argv[1] + ":" + sys.argv[ 2] + "@127.0.0.1:10332" bitcoin = AuthServiceProxy(bitcoin_req) def get_rounded_feerate(result): rate = str(int(result * 1000000) / 10.0) + " bsat/byte " if len(re.split("\.", rate)[0]) == 1: rate = " " + rate return rate try: mempool_info = bitcoin.getmempoolinfo() nextblock = [ "Next: ", bitcoin.estimatesmartfee(1, "ECONOMICAL")["feerate"] ] hour = ["1h: ", bitcoin.estimatesmartfee(6, "ECONOMICAL")["feerate"]] six_hours = [ "6h: ", bitcoin.estimatesmartfee(6 * 6, "ECONOMICAL")["feerate"] ] twelve_hours = [ "12h: ", bitcoin.estimatesmartfee(6 * 12, "ECONOMICAL")["feerate"] ] day = [ "1d: ", bitcoin.estimatesmartfee(144, "ECONOMICAL")["feerate"] ] week = [
prv_txid = unspent_tx[0]['txid'].encode('ascii','ignore') #learnd about it after lots of stuggle, persistence, and persevrance -:) prv_tx_vout = long(unspent_tx[0]['vout']) #my testnet wallet address wallet_address = unspent_tx[0]['address'].encode('ascii','ignore') #get the hashed key and remember to hexlify the bytes wallet_hashed_pubkey = base58.b58decode_check(wallet_address)[1:].encode("hex") #grab the unspent amount from the transaction unspent_amount = long(unspent_tx[0]['amount'] * 100000000) #convert to satoshis #get the fee estimate. There are sophisticated ways to estimate but for this assignment I am using the simple method feeestimate = rpc_connection.estimatesmartfee(6) tx_fee = long(feeestimate['feerate']*100000000) #satoshis # calculate the change amount change_amount = unspent_amount - tx_fee #satoshis # 1. Create the raw transaction without using any bitcoin python library # 2. This transaction have 1 input and two output # 3. Input = prv_txid and 2 Outputs are a) OP_RETURN and b) Change # define the raw_tx class class raw_tx: version = struct.pack("<L", 2) tx_in_count = struct.pack("<B", 1) tx_in = {} #TEMP tx_out_count = struct.pack("<B", 2)
if len(sys.argv) < 7: raise Exception('feeloop.py <RPC username> <RPC password> <oauth1> <oauth2> <token1> <token2>') while True: bitcoin_req = "http://"+sys.argv[1]+":"+sys.argv[2]+"@127.0.0.1:8332" bitcoin = AuthServiceProxy(bitcoin_req) def get_rounded_feerate(result): rate = str(int(result*1000000)/10.0)+" sat/byte " if len(re.split("\.", rate)[0]) == 1: rate = " "+rate return rate try: mempool_info = bitcoin.getmempoolinfo() nextblock = ["Next: ", bitcoin.estimatesmartfee(1, "ECONOMICAL")["feerate"]] hour = ["1h: ", bitcoin.estimatesmartfee(6, "ECONOMICAL")["feerate"]] six_hours = ["6h: ", bitcoin.estimatesmartfee(6*6, "ECONOMICAL")["feerate"]] twelve_hours = ["12h: ", bitcoin.estimatesmartfee(6*12, "ECONOMICAL")["feerate"]] day = ["1d: ", bitcoin.estimatesmartfee(144, "ECONOMICAL")["feerate"]] half_week = ["3d: ", bitcoin.estimatesmartfee(int(144*3.5), "ECONOMICAL")["feerate"]] week = ["1wk: ", bitcoin.estimatesmartfee(144*7, "ECONOMICAL")["feerate"]] mem_min = ["Min: ", mempool_info["mempoolminfee"]] bitstampprice = urllib.request.urlopen("https://www.bitstamp.net/api/v2/ticker/btcusd/").read() latest_price = float(json.loads(bitstampprice)["last"]) price_for_250 = latest_price/4 # Price for 250 byte tx tweet = "" for estimate in [nextblock, hour, six_hours, twelve_hours, day, half_week, week, mem_min]: tweet += estimate[0]+get_rounded_feerate(estimate[1]) + " ${:0.2f}".format(round(price_for_250*float(estimate[1]),2))+"\n"
def makepayment(): try: rpc_connect = AuthServiceProxy("http://{}:{}@{}:{}".format(rpc_user,rpc_password,allowed_ip,rpc_port)) current_block_height = rpc_connect.getblockcount() onchain_peers = rpc_connect.getconnectioncount() chain_type = rpc_connect.getblockchaininfo()['chain'] onchain_balance = rpc_connect.getbalance() fasttx = rpc_connect.estimatesmartfee(2) medtx = rpc_connect.estimatesmartfee(6) slowtx = rpc_connect.estimatesmartfee(12) newaddress = rpc_connect.getnewaddress() packqraddr = pyqrcode.create(newaddress) packqraddr.svg("app/static/img/newaddress.svg", scale=8) if chain_type == "main": fasttxrate = u"~₿ " + str(fasttx['feerate']) medtxrate = u"~₿ " + str(medtx['feerate']) slowtxrate = u"~₿ " + str(slowtx['feerate']) else: fasttxrate = u"~t₿ " + str(fasttx['feerate']) medtxrate = u"~t₿ " + str(medtx['feerate']) slowtxrate = u"~t₿ " + str(slowtx['feerate']) if onchain_balance > 0 and chain_type == "main": onchain_balance = u"₿ " + str(onchain_balance) elif onchain_balance == 0: onchain_balance = u"₿ " + str(0) elif onchain_balance > 0 and chain_type == "test": onchain_balance = u"t₿ " + str(onchain_balance) else: onchain_balance = u"t₿ " + str(0) if chain_type == "test": chaintype_ln = "testnet" else: chaintype_ln = "mainnet" conn = True except: onchain_balance = "Offline!" fasttxrate, medtxrate, slowtxrate = "", "", "" conn = False try: os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA' with open(os.path.expanduser(lnd_dir_location + 'data/chain/bitcoin/{}/admin.macaroon'.format(chaintype_ln)), 'rb') as f: macaroon_bytes = f.read() macaroon = codecs.encode(macaroon_bytes, 'hex') cert = open(os.path.expanduser(lnd_dir_location + 'tls.cert'), 'rb').read() creds = grpc.ssl_channel_credentials(cert) channel = grpc.secure_channel('localhost:10009', creds) stub = lnrpc.LightningStub(channel) satbalance = stub.ChannelBalance(ln.ChannelBalanceRequest(), metadata=[('macaroon', macaroon)]) offchain_balance = u"ş " + str(format(satbalance.balance,',')) lninvoice = (stub.AddInvoice(ln.Invoice(), metadata=[('macaroon', macaroon)])).payment_request packlnaddr = pyqrcode.create(lninvoice) packqraddr.svg("app/static/img/lninvoice.svg", scale=8) except: offchain_balance = "Offline!" if conn == True: if request.method == 'POST': if request.form['action'] == "sendbutton": if request.form['fee'] == "medfee": try: txid = rpc_connect.sendtoaddress(request.form['address'], request.form['amt'], "", "", False, True, medtx['blocks']) return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=True, txid=txid, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) except: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=False, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) elif request.form['fee'] == "highfee": try: txid = rpc_connect.sendtoaddress(request.form['address'], request.form['amt'], "", "", False, True, fasttx['blocks']) return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=True, txid=txid, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) except: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=False, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) elif request.form['fee'] == "lowfee": try: txid = rpc_connect.sendtoaddress(request.form['address'], request.form['amt'], "", "", False, True, slowtx['blocks']) return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=True, txid=txid, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) except: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=False, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) if request.form['action'] == "decodereq": try: os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA' with open(os.path.expanduser(lnd_dir_location + 'data/chain/bitcoin/{}/admin.macaroon'.format(chaintype_ln)), 'rb') as f: macaroon_bytes = f.read() macaroon = codecs.encode(macaroon_bytes, 'hex') cert = open(os.path.expanduser(lnd_dir_location + 'tls.cert'), 'rb').read() creds = grpc.ssl_channel_credentials(cert) channel = grpc.secure_channel('localhost:10009', creds) stub = lnrpc.LightningStub(channel) if len(request.form['reqtext']) > 20: req_whole = request.form['reqtext'] decoded_req = stub.DecodePayReq(ln.PayReqString(pay_req=req_whole), metadata=[('macaroon', macaroon)]) req_desc = decoded_req.description req_amt = u"ş " + str(format(decoded_req.num_satoshis,',')) req_to = decoded_req.destination with open("invoice.txt",'wb') as invoicefile: invoicefile.write(req_whole) invoicefile.close() return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx="N/A", req_desc=req_desc, req_amt=req_amt, req_to=req_to, switch=True, offchain_balance=offchain_balance, req_whole=req_whole, newaddress=newaddress, lninvoice=lninvoice) else: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx="N/A", switch=False, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) except: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx="N/A", switch=False, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) if request.form['action'] == "confirmbutton": try: os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA' with open(os.path.expanduser(lnd_dir_location + 'data/chain/bitcoin/{}/admin.macaroon'.format(chaintype_ln)), 'rb') as f: macaroon_bytes = f.read() macaroon = codecs.encode(macaroon_bytes, 'hex') cert = open(os.path.expanduser(lnd_dir_location + 'tls.cert'), 'rb').read() creds = grpc.ssl_channel_credentials(cert) channel = grpc.secure_channel('localhost:10009', creds) stub = lnrpc.LightningStub(channel) with open("invoice.txt",'r') as invoicefile: invoice_confirmed = invoicefile.read() try: result = stub.SendPaymentSync(ln.SendRequest(payment_request=str(invoice_confirmed)), metadata=[('macaroon', macaroon)]) if result.payment_error: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx="N/A", offchain_balance=offchain_balance, successln=False, error=result.payment_error, newaddress=newaddress, lninvoice=lninvoice) else: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx="N/A", offchain_balance=offchain_balance, successln=True, preimage=hexlify(result.payment_preimage), newaddress=newaddress, lninvoice=lninvoice) except: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=False, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) except: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx=False, offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) else: return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx="N/A", offchain_balance=offchain_balance, newaddress=newaddress, lninvoice=lninvoice) return render_template('makepayment.html', onchain_balance=onchain_balance, fasttxrate=fasttxrate, medtxrate=medtxrate, slowtxrate=slowtxrate, successfultx="N/A", offchain_balance=offchain_balance)