Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting "<function get_balance at 0x7f85fff6a4c0>" when trying to send balance with praw and bitcoinrpc

I am trying to make a cryptocurrency tipbot for Reddit in python. I am trying to see if I can communicate with BitcoinAPI and return stuff like balance. My bot should have commented the balance but just commented this:

<function get_balance at 0x7f85fff6a4c0>

What does this even mean?

This is my code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import praw
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException

# Authenticate with Reddit
reddit = praw.Reddit(
    client_id='',
    client_secret='',
    user_agent='',
    username='',
    password=''
)

reddit.validate_on_submit = True

# Print the username of the bot
print(reddit.user.me())

# TODO: Collect this data
#def getinboxdata(inboxdata):
# for item in reddit.inbox.all(limit=None):
#    print(repr(item))

def get_balance(address):
    rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:22555" % ('user', 'pass'))
    get_balance = rpc_connection.getbalance()
    return get_balance # This will print the balance

for item in reddit.inbox.unread(limit=None):
    if item.body == '+bunkertip':
        print('Bunkertip!')
        item.reply(get_balance)
        item.mark_read()
     

>Solution :

You’re passing the function get_balance to item.reply. You need to call get balance and pass the result to item.reply. E.G.

item.reply(get_balance())

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading