| 408 | } |
| 409 | |
| 410 | func ReadScript(reader io.Reader, maxAllowed uint32, fieldName string) (script []byte, err error) { |
| 411 | count, err := util.ReadVarInt(reader) |
| 412 | if err != nil { |
| 413 | return |
| 414 | } |
| 415 | if count > uint64(maxAllowed) { |
| 416 | log.Debug("ReadScript size err") |
| 417 | err = errcode.New(errcode.ScriptErrScriptSize) |
| 418 | return |
| 419 | } |
| 420 | //buf := scriptPool.Borrow(count) |
| 421 | script = make([]byte, count) |
| 422 | _, err = io.ReadFull(reader, script) |
| 423 | if err != nil { |
| 424 | //scriptPool.Return(buf) |
| 425 | return |
| 426 | } |
| 427 | return script, nil |
| 428 | |
| 429 | } |
| 430 | |
| 431 | func (s *Script) ExtractDestinations() (sType int, addresses []*Address, sigCountRequired int, err error) { |
| 432 | sType, pubKeys, isStandard := s.IsStandardScriptPubKey() |