<h3>How do I send a Bitcoin address from an iPhone to my server?</h3>

<p><a href="https://stackoverflow.com/a/18297623/530160">Basic Python client socket example</a>:</p>

<blockquote>
  <p>Server side:</p>

<pre><code>import socket

serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind(('localhost', 8089))
serversocket.listen(5) # become a server socket, maximum 5 connections

while True:
    connection, address = serversocket.accept()
    buf = connection.recv(64)
    if len(buf) &gt; 0:
        print buf
        break
</code></pre>
  
  <p>Client Side:</p>

<pre><code>import socket

clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect(('localhost', 8089))
clientsocket.send('hello')
</code></pre>
</blockquote>

<h3>How do I make a Bitcoin transaction using Python from my server?</h3>

<p><a href="https://bitcoin.stackexchange.com/questions/24571/how-to-make-a-simple-payment-with-the-python-bitcoinlib">How to make a simple payment with the python-bitcoinlib?</a></p>

<blockquote>
  <p>(Rewritten for brevity)</p>
  
  <p><a href="https://en.bitcoin.it/wiki/Running_Bitcoin#Linux_Quickstart" rel="nofollow noreferrer">Run
  bitcoind</a>,
  install python-bitcoinlib, then run this code:</p>

<pre><code>from bitcoin.core import COIN, b2lx
from bitcoin.base58 import CBitcoinAddress
import bitcoin.wallet
import bitcoin.rpc

rpc = bitcoin.rpc.Proxy()
addr = CBitcoinAddress('1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T')

txid = rpc.sendtoaddress(addr, 0.001 * COIN)
print(b2lx(txid))
</code></pre>
</blockquote>

CC BY-SA 3.0
2015-01-18T20:20:41.027Z
2015-01-18T20:27:21.080Z
2017-05-23T12:34:59.703Z
Nick ODell
<p>Background I just got started yesterday learning Python and I'm currently building my first iPhone game.</p>

<p>What I'm trying to do is create a Bitcoin Pot Jar inside an iPhone app like Sarutobi:<a href="https://itunes.apple.com/us/app/id932194840?mt=8" rel="nofollow">https://itunes.apple.com/us/app/id932194840?mt=8</a></p>

<p>You can test out the game to see how it works. All the user does is paste their bitcoin address in an input field, somehow this data goes somewhere and then the user receives randomly small tip during gameplay. How do I create something like this? What code is used to make this work?</p>

CC BY-SA 3.0
2015-01-18T17:16:03.643Z
What is this?: client_pass = "dadfisasf#@$sdf3sfR"
bluebit
CC BY-SA 3.0
2015-01-18T17:43:21.713Z
I think this may be off-topic because this is a general programming question that is better suited for stackexchange.com.
cdecker
CC BY-SA 3.0
2015-01-18T18:01:39.687Z
I was sent here from stackexchange.com and now you're telling me to go back? http://stackoverflow.com/questions/28012008/how-to-send-bitcoin-address-from-iphone-to-server-and-then-send-bitcoin-back-to?noredirect=1#comment44412677_28012008
bluebit
CC BY-SA 3.0
2015-01-18T20:02:15.813Z
@cdecker While this is an incredibly broad question, its scope lies entirely within cryptocurrency. I've going to vote to leave open.
Nick ODell
CC BY-SA 3.0
2015-01-18T20:17:06.280Z
@bluebit You should get more familiar with Web Services. Bassically iPhone will send request for invoking method to Web Service that lies on your server. Server will create and broadcast the transaction. - Sorry for previously misleading link.
Marek
CC BY-SA 3.0
2015-01-19T00:32:51.507Z
Ok, so this looks a lot harder than I expected. I'm totally new to code. Can someone breakdown a list of what I need to learn to accomplish my goal. Do I need my buy own Server or can I use an online service? I've been looking at resources on how to code, but there are so many languages, and everybody says something different, I need a good teacher.
bluebit
CC BY-SA 3.0
2015-01-19T22:11:31.200Z
@bluebit Please only ask one question per post.
Nick ODell
CC BY-SA 3.0
2015-01-19T23:22:44.467Z
I don't mean to be discouraging, but a project that involves transferring real money around (yes, Bitcoin is real money) is not a good idea for someone who's "totally new to code". You can very easily get all your money stolen, for one thing. I'd suggest starting with something much simpler.
Nate Eldredge
<bitcoind><bitcoin-core><python>
How to send user input data(Bitcoin address) from iPhone to server and then send Bitcoin back to user's Bitcoin address?
bluebit
# How to send user input data(Bitcoin address) from iPhone to server and then send Bitcoin back to user's Bitcoin address?

(Asked by: username_0 on 2015-01-18)

Background I just got started yesterday learning Python and I'm currently building my first iPhone game.

What I'm trying to do is create a Bitcoin Pot Jar inside an iPhone app like Sarutobi:<https://itunes.apple.com/us/app/id932194840?mt=8>

You can test out the game to see how it works. All the user does is paste their bitcoin address in an input field, somehow this data goes somewhere and then the user receives randomly small tip during gameplay. How do I create something like this? What code is used to make this work?

**Tags:** bitcoind, bitcoin-core, python

> **Comments:**
> **username_0**: What is this?: client_pass = "dadfisasf#@$sdf3sfR"  
> **username_1**: I think this may be off-topic because this is a general programming question that is better suited for stackexchange.com.  
> **username_0**: I was sent here from stackexchange.com and now you're telling me to go back? http://stackoverflow.com/questions/28012008/how-to-send-bitcoin-address-from-iphone-to-server-and-then-send-bitcoin-back-to?noredirect=1#comment44412677_28012008  
> **username_2**: @username_1 While this is an incredibly broad question, its scope lies entirely within cryptocurrency. I've going to vote to leave open.  
> **username_3**: @username_0 You should get more familiar with Web Services. Bassically iPhone will send request for invoking method to Web Service that lies on your server. Server will create and broadcast the transaction. - Sorry for previously misleading link.  
> **username_0**: Ok, so this looks a lot harder than I expected. I'm totally new to code. Can someone breakdown a list of what I need to learn to accomplish my goal. Do I need my buy own Server or can I use an online service? I've been looking at resources on how to code, but there are so many languages, and everybody says something different, I need a good teacher.  
> **username_2**: @username_0 Please only ask one question per post.  
> **username_4**: I don't mean to be discouraging, but a project that involves transferring real money around (yes, Bitcoin is real money) is not a good idea for someone who's "totally new to code". You can very easily get all your money stolen, for one thing. I'd suggest starting with something much simpler.  

---

## 1 answers

### Answer by username_2 on 2015-01-18. Score: 3

### How do I send a Bitcoin address from an iPhone to my server?

[Basic Python client socket example](https://stackoverflow.com/a/18297623/530160):

> Server side:
>
> ```
> import socket
>
> serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> serversocket.bind(('localhost', 8089))
> serversocket.listen(5) # become a server socket, maximum 5 connections
>
> while True:
>     connection, address = serversocket.accept()
>     buf = connection.recv(64)
>     if len(buf) > 0:
>         print buf
>         break
>
> ```
>
> Client Side:
>
> ```
> import socket
>
> clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> clientsocket.connect(('localhost', 8089))
> clientsocket.send('hello')
>
> ```

### How do I make a Bitcoin transaction using Python from my server?

[How to make a simple payment with the python-bitcoinlib?](https://bitcoin.stackexchange.com/questions/24571/how-to-make-a-simple-payment-with-the-python-bitcoinlib)

> (Rewritten for brevity)
>
> [Run
> bitcoind](https://en.bitcoin.it/wiki/Running_Bitcoin#Linux_Quickstart),
> install python-bitcoinlib, then run this code:
>
> ```
> from bitcoin.core import COIN, b2lx
> from bitcoin.base58 import CBitcoinAddress
> import bitcoin.wallet
> import bitcoin.rpc
>
> rpc = bitcoin.rpc.Proxy()
> addr = CBitcoinAddress('1JwSSubhmg6iPtRjtyqhUYYH7bZg3Lfy1T')
>
> txid = rpc.sendtoaddress(addr, 0.001 * COIN)
> print(b2lx(txid))
>
> ```


---

