diff --git a/rpcserver.go b/rpcserver.go
index <HASH>..<HASH> 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -887,7 +887,7 @@ func handleGetRawTransaction(s *rpcServer, cmd btcjson.Cmd, walletNotification c
 			vinList[i].Sequence = float64(v.Sequence)
 			disbuf, _ := btcscript.DisasmString(v.SignatureScript)
 			vinList[i].ScriptSig.Asm = strings.Replace(disbuf, " ", "", -1)
-			vinList[i].Vout = i + 1
+			vinList[i].Vout = int(v.PreviousOutpoint.Index)
 			rpcsLog.Debugf(disbuf)
 		}
Correctly set vout for getrawtransaction.

The vout field (as part of the getrawtransaction JSON reply) should be
set to the input's previous outpoint's index, not the current input
index.

Found by flam and reported on IRC. Thanks!