WIP: next hard fork #5
1 changed files with 13 additions and 8 deletions
|
@ -791,20 +791,25 @@ func MultiSigScript(pubkeys []*btcutil.AddressPubKey, nrequired int) ([]byte, er
|
||||||
|
|
||||||
// PushedData returns an array of byte slices containing any pushed data found
|
// PushedData returns an array of byte slices containing any pushed data found
|
||||||
// in the passed script. This includes OP_0, but not OP_1 - OP_16.
|
// in the passed script. This includes OP_0, but not OP_1 - OP_16.
|
||||||
|
//
|
||||||
|
// NOTE: This function is only valid for version 0 scripts. Since the function
|
||||||
|
// does not accept a script version, the results are undefined for other script
|
||||||
|
// versions.
|
||||||
func PushedData(script []byte) ([][]byte, error) {
|
func PushedData(script []byte) ([][]byte, error) {
|
||||||
pops, err := parseScript(script)
|
const scriptVersion = 0
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var data [][]byte
|
var data [][]byte
|
||||||
for _, pop := range pops {
|
tokenizer := MakeScriptTokenizer(scriptVersion, script)
|
||||||
if pop.data != nil {
|
for tokenizer.Next() {
|
||||||
data = append(data, pop.data)
|
if tokenizer.Data() != nil {
|
||||||
} else if pop.opcode.value == OP_0 {
|
data = append(data, tokenizer.Data())
|
||||||
|
} else if tokenizer.Opcode() == OP_0 {
|
||||||
data = append(data, nil)
|
data = append(data, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := tokenizer.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue