2017-09-09 22:54:58 -05:00
|
|
|
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)
|
2017-09-09 22:54:58 -05:00
|
|
|
|
|
|
|
return bytes.Compare(lockingHash, pubKeyHash) == 0
|
|
|
|
}
|