blockchain_go/transaction_input.go

20 lines
422 B
Go
Raw Normal View History

package main
import "bytes"
// TXInput represents a transaction input
type TXInput struct {
Txid []byte
Vout int
ScriptSig []byte
}
// UnlocksOutputWith checks whether the address initiated the transaction
func (in *TXInput) UnlocksOutputWith(pubKeyHash []byte) bool {
2017-09-09 23:06:12 -05:00
sigLen := 64
pubKey := in.ScriptSig[sigLen:]
lockingHash := HashPubKey(pubKey)
return bytes.Compare(lockingHash, pubKeyHash) == 0
}