bad-txns-nonstandard-inputs error after sendrawtransaction I smashed my head over the table trying to send raw transaction and every time get the same error bad-txns-nonstandard-inputs.



So, here is what I do:


Get unspent transactions 

bitcoin-cli listunspent
[
  {
    "txid": "txid_number_1",
    "vout": 1,
    "address": "address_1",
    "redeemScript": "redeemScript_1",
    "scriptPubKey": "scriptPubKey_1",
    "amount": 0.00024972,
    "confirmations": 31,
    "spendable": true,
    "solvable": true,
    "safe": true
  }
]

Create raw transaction with tx_id and vout taken above 

bitcoin-cli createrawtransaction '[{"txid":"txid_number_1","vout":1}]' '{"address_to_sent":0.00002000}'



tx_id_as_hexstring = 

02000000016affa8a874987f66be3ab4791b57042cbf0912088352ba0e3931b7b8b8f374c80100000000ffffffff01d0070000000000001976a9147c99343bb9cba8699e7f7b4f5552357e477dc76188ac00000000



Sign raw transaction

bitcoin-cli signrawtransaction tx_id_as_hexstring

Send raw transaction

bitcoin-cli sendrawtransaction tx_id_as_hexstring

error code: -26
error message:
64: bad-txns-nonstandard-inputs





I tried to create same transaction with coinb.in, but result is the same.

What am I doing wrong?



Also

bitcoin-cli decoderawtransaction tx_id_as_hexstring

returns 

{
  "txid": "txid_number_2",
  "hash": "txid_number_2",
  "version": 2,
  "size": 85,
  "vsize": 85,
  "locktime": 0,
  "vin": [
    {
      "txid": "txid_number_3",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.00002000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 7c99343bb9cba8699e7f7b4f5552357e477dc761 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a9147c99343bb9cba8699e7f7b4f5552357e477dc76188ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "address_to_sent"
        ]
      }
    }
  ]
}
Your transaction is not being signed.

First of all, the hex string that createrawtransaction gives you is not the txid, it is the transaction itself. That transaction is not stored in your wallet. 

When you pass it to signrawtransaction, the raw transaction will be signed and returned to you (it will be the thing under the hex field in the returned object. Again, this transaction is not stored in your wallet. That signed transaction is what you pass to sendrawtransaction, not the thing that createrawtransaction gives you.