Enable txindex=1 as default #37
3 changed files with 11 additions and 14 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"crypto/sha256"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
|
@ -331,8 +332,10 @@ func (vm *Engine) executeOpcode(pop *parsedOpcode) error {
|
|||
// provided position in the script. It does no error checking and leaves that
|
||||
// to the caller to provide a valid offset.
|
||||
func (vm *Engine) disasm(scriptIdx int, scriptOff int) string {
|
||||
return fmt.Sprintf("%02x:%04x: %s", scriptIdx, scriptOff,
|
||||
vm.scripts[scriptIdx][scriptOff].print(false))
|
||||
var buf strings.Builder
|
||||
pop := vm.scripts[scriptIdx][scriptOff]
|
||||
disasmOpcode(&buf, pop.opcode, pop.data, false)
|
||||
return fmt.Sprintf("%02x:%04x: %s", scriptIdx, scriptOff, buf.String())
|
||||
}
|
||||
|
||||
// validPC returns an error if the current script position is valid for
|
||||
|
|
|
@ -740,14 +740,6 @@ func disasmOpcode(buf *strings.Builder, op *opcode, data []byte, compact bool) {
|
|||
buf.WriteString(fmt.Sprintf(" 0x%02x", data))
|
||||
}
|
||||
|
||||
// print returns a human-readable string representation of the opcode for use
|
||||
// in script disassembly.
|
||||
func (pop *parsedOpcode) print(compact bool) string {
|
||||
var buf strings.Builder
|
||||
disasmOpcode(&buf, pop.opcode, pop.data, compact)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// bytes returns any data associated with the opcode encoded as it would be in
|
||||
// a script. This is used for unparsing scripts from parsed opcodes.
|
||||
func (pop *parsedOpcode) bytes() ([]byte, error) {
|
||||
|
|
|
@ -127,8 +127,9 @@ func TestOpcodeDisasm(t *testing.T) {
|
|||
expectedStr = "OP_UNKNOWN" + strconv.Itoa(opcodeVal)
|
||||
}
|
||||
|
||||
pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data}
|
||||
gotStr := pop.print(true)
|
||||
var buf strings.Builder
|
||||
disasmOpcode(&buf, &opcodeArray[opcodeVal], data, true)
|
||||
gotStr := buf.String()
|
||||
if gotStr != expectedStr {
|
||||
t.Errorf("pop.print (opcode %x): Unexpected disasm "+
|
||||
"string - got %v, want %v", opcodeVal, gotStr,
|
||||
|
@ -193,8 +194,9 @@ func TestOpcodeDisasm(t *testing.T) {
|
|||
expectedStr = "OP_UNKNOWN" + strconv.Itoa(opcodeVal)
|
||||
}
|
||||
|
||||
pop := parsedOpcode{opcode: &opcodeArray[opcodeVal], data: data}
|
||||
gotStr := pop.print(false)
|
||||
var buf strings.Builder
|
||||
disasmOpcode(&buf, &opcodeArray[opcodeVal], data, false)
|
||||
gotStr := buf.String()
|
||||
if gotStr != expectedStr {
|
||||
t.Errorf("pop.print (opcode %x): Unexpected disasm "+
|
||||
"string - got %v, want %v", opcodeVal, gotStr,
|
||||
|
|
Loading…
Add table
Reference in a new issue