Enable txindex=1 as default #37

Closed
kodxana wants to merge 211 commits from master into master
2 changed files with 23 additions and 5 deletions
Showing only changes of commit 55a6bb5e32 - Show all commits

View file

@ -100,11 +100,7 @@ func isWitnessScriptHash(pops []parsedOpcode) bool {
// IsPayToWitnessScriptHash returns true if the is in the standard // IsPayToWitnessScriptHash returns true if the is in the standard
// pay-to-witness-script-hash (P2WSH) format, false otherwise. // pay-to-witness-script-hash (P2WSH) format, false otherwise.
func IsPayToWitnessScriptHash(script []byte) bool { func IsPayToWitnessScriptHash(script []byte) bool {
pops, err := parseScript(script) return isWitnessScriptHashScript(script)
if err != nil {
return false
}
return isWitnessScriptHash(pops)
} }
// IsPayToWitnessPubKeyHash returns true if the is in the standard // IsPayToWitnessPubKeyHash returns true if the is in the standard

View file

@ -421,6 +421,28 @@ func isWitnessPubKeyHashScript(script []byte) bool {
return extractWitnessPubKeyHash(script) != nil return extractWitnessPubKeyHash(script) != nil
} }
// extractWitnessScriptHash extracts the witness script hash from the passed
// script if it is standard pay-to-witness-script-hash script. It will return
// nil otherwise.
func extractWitnessScriptHash(script []byte) []byte {
// A pay-to-witness-script-hash script is of the form:
// OP_0 OP_DATA_32 <32-byte-hash>
if len(script) == 34 &&
script[0] == OP_0 &&
script[1] == OP_DATA_32 {
return script[2:34]
}
return nil
}
// isWitnessScriptHashScript returns whether or not the passed script is a
// standard pay-to-witness-script-hash script.
func isWitnessScriptHashScript(script []byte) bool {
return extractWitnessScriptHash(script) != nil
}
// isNullData returns true if the passed script is a null data transaction, // isNullData returns true if the passed script is a null data transaction,
// false otherwise. // false otherwise.
func isNullData(pops []parsedOpcode) bool { func isNullData(pops []parsedOpcode) bool {