Bitcoin TX decode failed while sending to a the network(regtest) I have created a signature manually (referring the signature output formats in bitcoin-cli). But i tried to send the same to the network I am getting 

error code: -22

error message:

TX decode failed

Below is the signed tx

signed tx:

020000000138c059adfe41e80fb46e14d23949304343abc560a6fbcef4b2e3110f8241816d00000000002c2b0768616e756d616ea8201ca35897540ec7ae7294a8cacd11caf2c09f95f026c925c6ce4e4c29b20e3c4187ffffffff0280507401000000001976a9146a3ffadddae4ccb4223a8c7215d4b481daf6967788ac00d012130000000017a914def347cf3b01bf03a30d7ee9f62d86ed5109b5478700000000

Spliting the same signed tx:

02 00 00 00  // version

01   // number of inputs (var_uint)

38 c0 59 ad fe 41 e8 0f b4 6e 14 d2 39 49 30 43 43 ab c5 60 a6 fb ce f4 b2 e3 

11 0f 82 41 81 6d  // input transaction hash

00 00 00 00 00 //  input index

2c // size of script (var_uint)

2b // data needs to be pushed  the below 43 bytes will be pushed 

07 // push 7 bytes to stack

68 61 6e 75 6d 61 6e // data needs to be pushed

a8 // OP_HASH256 

20 // push 32 bytes

1c a3 58 97 54 0e c7 ae 72 94 a8 ca cd 11 ca f2 c0 9f 95 f0 26 c9 25 c6 ce 4e 

4c 29 b2 0e 3c 41 

87 // OP_EQUAL

ff ff ff ff // sequence

02  // no of vouts

80 50 74 01 00 00 00 00 // amount

19 // size of script (var_uint) 

76 //OP_DUP

a9 // OP_HAH160

14  // 20 bytes needs to be pushed

6a 3f fa dd da e4 cc b4 22 3a 8c 72 15 d4 b4 81 da f6 96 77 

88 // OP_EQUALVERIFY

ac //OP_CHECKSIG

00 d0 12 13 00 00 00 00 // amount

17 // size of script (var_uint) 

a9 //  OP_HASH160

14 // 20 bytes needs to be pushed

de f3 47 cf 3b 01 bf 03 a3 0d 7e e9 f6 2d 86 ed 51 09 b5 47 

87 // OP_EQUAL

00000000 // lock time

Can anyone please help me to find what is that I am missing ?
Your input txid output index is 5 bytes, when it should be 4 bytes. Just remove the extra 00 byte and the transaction will not pop an error. However, you might need to sign this transaction again as signature involves signing the entire serialized transaction as a message and by changing the txid outpoint you will change the message that is signed.