<p>The table of RPC commands can be found in <code>rpcserver.cpp</code> in the static array <code>vRPCCommands</code>.  From that you can see that the RPC command <code>sendtoaddress</code> is implemented by a C++ function named, appropriately enough, <code>sendtoaddress</code>.  A quick grep shows this function is defined in <code>rpcwallet.cpp</code>, and its work is done by calling <code>pwalletMain-&gt;SendMoney()</code>.  So <code>pwallet-&gt;SendMoney()</code> seems like the right function to call.</p>

CC BY-SA 3.0
2014-08-07T23:58:13.023Z
2014-08-07T23:58:13.023Z
Nate Eldredge
<p>I am messing with the Bitcoin sourcecode. </p>

<p>Normally when you want to send some BTC you type :</p>

<pre><code>./bitcoind sendtoaddress 1ADRESSS 0.001 
</code></pre>

<p>How would you do this in the sourcecode on a recurring basis? </p>

<p>So what code is needed to send a transaction to a specified address each time a block is created? Almost like a tax. and where would this code be placed? </p>

<p>I am learning the Inside of the Bitcoin protocol and C++ so any help would be great. </p>

CC BY-SA 3.0
2014-06-08T10:28:33.263Z
So you want a script that will spend your money without asking your permission? It's doable, but very dangerous. YOu would be better off looking at multi-signature or escrow transactions.
T9b
<transactions><bitcoind><bitcoin-core-development><sending>
Bitcoin Transaction within source code
user17120
# Bitcoin Transaction within source code

(Asked by: username_0 on 2014-06-07)

I am messing with the Bitcoin sourcecode.

Normally when you want to send some BTC you type :

```
./bitcoind sendtoaddress 1ADRESSS 0.001 

```

How would you do this in the sourcecode on a recurring basis?

So what code is needed to send a transaction to a specified address each time a block is created? Almost like a tax. and where would this code be placed?

I am learning the Inside of the Bitcoin protocol and C++ so any help would be great.

**Tags:** transactions, bitcoind, bitcoin-core-development, sending

> **Comments:**
> **username_1**: So you want a script that will spend your money without asking your permission? It's doable, but very dangerous. YOu would be better off looking at multi-signature or escrow transactions.  

---

## 1 answers

### Answer by username_2 on 2014-08-07. Score: 0

The table of RPC commands can be found in `rpcserver.cpp` in the static array `vRPCCommands`. From that you can see that the RPC command `sendtoaddress` is implemented by a C++ function named, appropriately enough, `sendtoaddress`. A quick grep shows this function is defined in `rpcwallet.cpp`, and its work is done by calling `pwalletMain->SendMoney()`. So `pwallet->SendMoney()` seems like the right function to call.


---

