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

View File

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