<p>You provided the amount incorrectly. The amount is <code>0.54551</code> not <code>545500</code>. This is important as Segwit inputs include the previous output's amount in the signature. Providing the wrong amount will result in the wrong signature which will then fail validation.</p>

CC BY-SA 4.0
2018-06-15T23:23:36.803Z
2018-06-15T23:23:36.803Z
Ava Chow
<p>I am creating a raw transaction to send amount from <strong>from_address</strong> to <strong>to_address</strong>. While sending a transaction I got an error. I posted the detailed process of creating a raw transaction. Could anyone tell me where it was going wrong?</p>

<pre><code>from_address = '2NAvmqmZmodXKDHyWQaRufsFptZ6cDPVaPQ'
to_address = '2MyTfwJFbWYueyFpDjdN8cJ4ZwsSA7UfN8s'
</code></pre>

<p>Unspent of <strong>from_address</strong></p>

<pre><code>[{'txid': '421ac74f3fb137ea0f65d20e71825abefd463322b4e4a9033057e78e2a27bb69', 'vout': 1, 'address': '2NAvmqmZmodXKDHyWQaRufsFptZ6cDPVaPQ', 'account': '', 'redeemScript': '00140363a5b9ce91754185b3d39d292f262ac3f417c5', 'scriptPubKey': 'a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c687', 'amount': 0.5455, 'confirmations': 108, 'spendable': True, 'solvable': True, 'safe': True}]
</code></pre>

<p>creating rawtransaction</p>

<pre><code>bitcoin-cli createrawtransaction [{'txid': '421ac74f3fb137ea0f65d20e71825abefd463322b4e4a9033057e78e2a27bb69', 'vout': 1}] {'2MyTfwJFbWYueyFpDjdN8cJ4ZwsSA7UfN8s' : 0.0495 ,'2NAvmqmZmodXKDHyWQaRufsFptZ6cDPVaPQ' : 0.4955}
</code></pre>

<p>signing the transaction</p>

<pre><code>bitcoin-cli signrawtransaction '020000000169bb272a8ee7573003a9e4b4223346fdbe5a82710ed2650fea37b13f4fc71a420100000000ffffffff02f0874b000000000017a9149ca7d200ee0b4e751d1de0c56fd3cf8defde173d87b012f4020000000017a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c68700000000' [{'txid': '421ac74f3fb137ea0f65d20e71825abefd463322b4e4a9033057e78e2a27bb69', 'vout': 1, 'redeemScript': '00140363a5b9ce91754185b3d39d292f262ac3f417c5', 'scriptPubKey': 'a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c687', 'amount': 545500}] ['cR5YAMiTGaAwFgrEHeXK2MpEm8SEBFXm7pf2R2m6SNBx3sRqvPYw']
</code></pre>

<p>sendrawtransaction</p>

<pre><code>bitcoin-cli sendrawtransaction '0200000000010169bb272a8ee7573003a9e4b4223346fdbe5a82710ed2650fea37b13f4fc71a4201000000171600140363a5b9ce91754185b3d39d292f262ac3f417c5ffffffff02f0874b000000000017a9149ca7d200ee0b4e751d1de0c56fd3cf8defde173d87b012f4020000000017a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c68702483045022100ccf694b3439a163ca100743c749ba80e6732d96e2f1dc951ea38c6aba7624cf102203463130bec546cd5cf5d0a18067b51cdd63b879eb34cbecf61b2883ee58021110121034fb6dfc450dd53dcb083cb38ad8ad4d5ad744e3da6c93b579eb19354c3ff2e6600000000'
</code></pre>

<p>Error:</p>

<pre><code>raise Exception('Error in RPC call: ' + str(responseJSON['error']))
Exception: Error in RPC call: {'code': -26, 'message': '64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation)'}
</code></pre>

CC BY-SA 4.0
2018-06-15T16:50:57.217Z
Try signing with full BTC amount (0.5455) not in satoshis
m1xolyd1an
CC BY-SA 4.0
2018-06-15T18:57:52.943Z
also see Gavin's multisig example here: https://gist.github.com/gavinandresen/3966071
pebwindkraft
<transactions><raw-transaction><createrawtransaction><signrawtransaction><sendrawtransaction>
Error in creating bitcoin raw transaction
merklexy
# Error in creating bitcoin raw transaction

(Asked by: username_0 on 2018-06-15)

I am creating a raw transaction to send amount from **from\_address** to **to\_address**. While sending a transaction I got an error. I posted the detailed process of creating a raw transaction. Could anyone tell me where it was going wrong?

```
from_address = '2NAvmqmZmodXKDHyWQaRufsFptZ6cDPVaPQ'
to_address = '2MyTfwJFbWYueyFpDjdN8cJ4ZwsSA7UfN8s'

```

Unspent of **from\_address**

```
[{'txid': '421ac74f3fb137ea0f65d20e71825abefd463322b4e4a9033057e78e2a27bb69', 'vout': 1, 'address': '2NAvmqmZmodXKDHyWQaRufsFptZ6cDPVaPQ', 'account': '', 'redeemScript': '00140363a5b9ce91754185b3d39d292f262ac3f417c5', 'scriptPubKey': 'a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c687', 'amount': 0.5455, 'confirmations': 108, 'spendable': True, 'solvable': True, 'safe': True}]

```

creating rawtransaction

```
bitcoin-cli createrawtransaction [{'txid': '421ac74f3fb137ea0f65d20e71825abefd463322b4e4a9033057e78e2a27bb69', 'vout': 1}] {'2MyTfwJFbWYueyFpDjdN8cJ4ZwsSA7UfN8s' : 0.0495 ,'2NAvmqmZmodXKDHyWQaRufsFptZ6cDPVaPQ' : 0.4955}

```

signing the transaction

```
bitcoin-cli signrawtransaction '020000000169bb272a8ee7573003a9e4b4223346fdbe5a82710ed2650fea37b13f4fc71a420100000000ffffffff02f0874b000000000017a9149ca7d200ee0b4e751d1de0c56fd3cf8defde173d87b012f4020000000017a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c68700000000' [{'txid': '421ac74f3fb137ea0f65d20e71825abefd463322b4e4a9033057e78e2a27bb69', 'vout': 1, 'redeemScript': '00140363a5b9ce91754185b3d39d292f262ac3f417c5', 'scriptPubKey': 'a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c687', 'amount': 545500}] ['cR5YAMiTGaAwFgrEHeXK2MpEm8SEBFXm7pf2R2m6SNBx3sRqvPYw']

```

sendrawtransaction

```
bitcoin-cli sendrawtransaction '0200000000010169bb272a8ee7573003a9e4b4223346fdbe5a82710ed2650fea37b13f4fc71a4201000000171600140363a5b9ce91754185b3d39d292f262ac3f417c5ffffffff02f0874b000000000017a9149ca7d200ee0b4e751d1de0c56fd3cf8defde173d87b012f4020000000017a914c1f4f356a6c6d28742dd1e80270edd55e6a5b0c68702483045022100ccf694b3439a163ca100743c749ba80e6732d96e2f1dc951ea38c6aba7624cf102203463130bec546cd5cf5d0a18067b51cdd63b879eb34cbecf61b2883ee58021110121034fb6dfc450dd53dcb083cb38ad8ad4d5ad744e3da6c93b579eb19354c3ff2e6600000000'

```

Error:

```
raise Exception('Error in RPC call: ' + str(responseJSON['error']))
Exception: Error in RPC call: {'code': -26, 'message': '64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation)'}

```

**Tags:** transactions, raw-transaction, createrawtransaction, signrawtransaction, sendrawtransaction

> **Comments:**
> **username_1**: Try signing with full BTC amount (0.5455) not in satoshis  
> **username_2**: also see Gavin's multisig example here: https://gist.github.com/gavinandresen/3966071  

---

## 1 answers

### Answer by username_3 on 2018-06-15. Score: 3

You provided the amount incorrectly. The amount is `0.54551` not `545500`. This is important as Segwit inputs include the previous output's amount in the signature. Providing the wrong amount will result in the wrong signature which will then fail validation.


---

