chainntnfs/txnotifier: stricter confirmation matching via scripts

This commit is contained in:
Conner Fromknecht 2019-06-27 19:10:58 -07:00
parent e10d4e9047
commit 50f7f7f1b7
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -192,18 +192,22 @@ func (r ConfRequest) ConfHintKey() ([]byte, error) {
// the outputs of the transaction to determine if it matches. Otherwise, we'll
// match on the txid.
func (r ConfRequest) MatchesTx(tx *wire.MsgTx) bool {
if r.TxID != ZeroHash {
return r.TxID == tx.TxHash()
}
pkScript := r.PkScript.Script()
for _, txOut := range tx.TxOut {
if bytes.Equal(txOut.PkScript, pkScript) {
return true
scriptMatches := func() bool {
pkScript := r.PkScript.Script()
for _, txOut := range tx.TxOut {
if bytes.Equal(txOut.PkScript, pkScript) {
return true
}
}
return false
}
return false
if r.TxID != ZeroHash {
return r.TxID == tx.TxHash() && scriptMatches()
}
return scriptMatches()
}
// ConfNtfn represents a notifier client's request to receive a notification