<p><strong>You cannot spend bitcoins of a given BTC address if you do not own the private key of such address. Only private keys allows you to sign and broadcast a valid spendable tx.</strong></p>

<p>It's safe to specify also some peculiarity of <code>creatrawtransaction</code> RPC:</p>

<p>The <code>createrawtransaction</code> RPC command creates an unsigned transaction that will spend a previous output to a new output with a P2PKH or P2SH address. 
<em>The transaction is not stored in the wallet or transmitted to the network at this stage. It needs to be signed with a valid corresponding private key for the address we want to spend address from.</em></p>

<p>Given Parameter #1 (references to previous outputs) &amp; Parameter #2 (P2PKH or P2SH addresses and amounts) we get a result in the forum of an unsigned raw transaction in hex.</p>

CC BY-SA 4.0
2019-01-16T05:46:21.233Z
i guess! rawtransaction needs signing. so without signrawtransaction, block will reject this transaction
user10865941
CC BY-SA 4.0
2019-01-15T11:00:36.263Z
2019-01-15T11:00:36.263Z
AG23
<blockquote>
  <p>in conclusion, it doesn't works but i want know why this code not working</p>
</blockquote>

<p>This part <code>{"MY WALLET ADDRESS": 1.0, "3LnZGyRAeCA3LAMBU2RSQn6dAkHw8rWquw": fee}</code> will throw an error, but the more general answer about security is: </p>

<p>You can only generate a valid transaction if the wallet file you have open contains the private keys that can sign the transaction you've made. <strong>If you can't produce a valid signature, then it will not be a valid transaction, and the network will not relay or confirm it.</strong>  </p>

CC BY-SA 4.0
2019-01-15T09:47:58.890Z
i think createrawtransaction working [{"txid ", "my wallet address", "another wallet address"}] so where is validation part on this command?
user10865941
CC BY-SA 4.0
2019-01-15T10:05:29.867Z
@user10865941: All other nodes validate the transaction - they check that you have provided proof that you posess the private key.
RedGrittyBrick
CC BY-SA 4.0
2019-01-16T01:41:14.487Z
@user10865941 the output of `createrawtransaction` is an unsigned bitcoin transaction. Next you would need to call `signrawtransaction` to create a valid transaction, but your client will be unable to do so unless it has the relevant private keys. If you cannot produce a valid signature, then the network will not accept it as a valid transaction.
chytrik
CC BY-SA 4.0
2019-01-15T08:16:15.010Z
2019-01-15T08:16:15.010Z
chytrik
<p>i'm studying 'Mastering Bitcoin' and have a questions,</p>

<p>in this book, we can send coin to other wallet by <code>createrawtransaction</code> but there is no enough secure method.</p>

<p>we can find other's wallet addresses at <a href="https://www.blockchain.com" rel="nofollow noreferrer">https://www.blockchain.com</a>. and unused coin value too.</p>

<p>for example - <a href="https://www.blockchain.com/en/btc/address/34bN2MQcqA4JpbEVRU9KBsvhXgSEHQrqBz" rel="nofollow noreferrer">https://www.blockchain.com/en/btc/address/34bN2MQcqA4JpbEVRU9KBsvhXgSEHQrqBz</a></p>

<blockquote>
  <p>718ae88f0eb13d2f2d3bc74cbf18721a82739b80f1bfc0658ed699263fca76fd(Fee:
  0.00002057 BTC - 3.11 sat/WU - 8.33 sat/B - Size: 247 bytes) 2019-01-14 04:57:04 34bN2MQcqA4JpbEVRU9KBsvhXgSEHQrqBz (1.13215222 BTC
  - Output) 32T5urH6uN4jhKenhW4LWM66WouzSCERbA - (Spent) 0.03213165 BTC <strong>3LnZGyRAeCA3LAMBU2RSQn6dAkHw8rWquw</strong> - (Unspent) 1.1 BTC</p>
</blockquote>

<p>than we can make fake transaction such as</p>

<blockquote>
  <p>$bitcoin-cli createrawtransaction '[{"txid" :
  "718ae88f0eb13d2f2d3bc74cbf18721a82739b80f1bfc0658ed699263fca76fd","vout":0}]'
  ' {"MY WALLET ADDRESS": 1.0, "<strong>3LnZGyRAeCA3LAMBU2RSQn6dAkHw8rWquw</strong>":
  fee}'</p>
</blockquote>

<p>in conclusion, it doesn't works but i want know why this code not working</p>

<bitcoind>
how bitcoin reject invalid transaction? (with createrawtransaction)
user10865941
# how bitcoin reject invalid transaction? (with createrawtransaction)

(Asked by: username_0 on 2019-01-15)

i'm studying 'Mastering Bitcoin' and have a questions,

in this book, we can send coin to other wallet by `createrawtransaction` but there is no enough secure method.

we can find other's wallet addresses at <https://www.blockchain.com>. and unused coin value too.

for example - <https://www.blockchain.com/en/btc/address/34bN2MQcqA4JpbEVRU9KBsvhXgSEHQrqBz>

> 718ae88f0eb13d2f2d3bc74cbf18721a82739b80f1bfc0658ed699263fca76fd(Fee:
> 0.00002057 BTC - 3.11 sat/WU - 8.33 sat/B - Size: 247 bytes) 2019-01-14 04:57:04 34bN2MQcqA4JpbEVRU9KBsvhXgSEHQrqBz (1.13215222 BTC
> - Output) 32T5urH6uN4jhKenhW4LWM66WouzSCERbA - (Spent) 0.03213165 BTC **3LnZGyRAeCA3LAMBU2RSQn6dAkHw8rWquw** - (Unspent) 1.1 BTC

than we can make fake transaction such as

> $bitcoin-cli createrawtransaction '[{"txid" :
> "718ae88f0eb13d2f2d3bc74cbf18721a82739b80f1bfc0658ed699263fca76fd","vout":0}]'
> ' {"MY WALLET ADDRESS": 1.0, "**3LnZGyRAeCA3LAMBU2RSQn6dAkHw8rWquw**":
> fee}'

in conclusion, it doesn't works but i want know why this code not working

**Tags:** bitcoind


---

## 2 answers

### Answer by username_2 on 2019-01-15. Score: 3 | Accepted answer

> in conclusion, it doesn't works but i want know why this code not working

This part `{"MY WALLET ADDRESS": 1.0, "3LnZGyRAeCA3LAMBU2RSQn6dAkHw8rWquw": fee}` will throw an error, but the more general answer about security is:

You can only generate a valid transaction if the wallet file you have open contains the private keys that can sign the transaction you've made. **If you can't produce a valid signature, then it will not be a valid transaction, and the network will not relay or confirm it.**

> **Comments:**
> **username_0**: i think createrawtransaction working [{"txid ", "my wallet address", "another wallet address"}] so where is validation part on this command?  
> **username_3**: @username_0: All other nodes validate the transaction - they check that you have provided proof that you posess the private key.  
> **username_2**: @username_0 the output of `createrawtransaction` is an unsigned bitcoin transaction. Next you would need to call `signrawtransaction` to create a valid transaction, but your client will be unable to do so unless it has the relevant private keys. If you cannot produce a valid signature, then the network will not accept it as a valid transaction.  

---

### Answer by username_1 on 2019-01-15. Score: 0

**You cannot spend bitcoins of a given BTC address if you do not own the private key of such address. Only private keys allows you to sign and broadcast a valid spendable tx.**

It's safe to specify also some peculiarity of `creatrawtransaction` RPC:

The `createrawtransaction` RPC command creates an unsigned transaction that will spend a previous output to a new output with a P2PKH or P2SH address.
*The transaction is not stored in the wallet or transmitted to the network at this stage. It needs to be signed with a valid corresponding private key for the address we want to spend address from.*

Given Parameter #1 (references to previous outputs) & Parameter #2 (P2PKH or P2SH addresses and amounts) we get a result in the forum of an unsigned raw transaction in hex.

> **Comments:**
> **username_0**: i guess! rawtransaction needs signing. so without signrawtransaction, block will reject this transaction  

---

