Skip to content

Commit

Permalink
dex/networks/btc: ExtractScriptAddrs never errors
Browse files Browse the repository at this point in the history
The updated txscript.ExtractPkScriptAddrs always returns a nil error.
Keep the error return on ExtractScriptAddrs for now since it was not
removed from ExtractPkScriptAddrs and it could have meaning again.
  • Loading branch information
chappjc committed May 20, 2022
1 parent 8e2f66f commit d0d2636
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dex/networks/btc/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func ExtractScriptAddrs(script []byte, chainParams *chaincfg.Params) (*BtcScript
// For P2SH and non-P2SH multi-sig, pull the addresses from the pubkey script.
class, addrs, numRequired, err := txscript.ExtractPkScriptAddrs(script, chainParams)
nonStandard := class == txscript.NonStandardTy
if err != nil {
if err != nil { // txscript.ExtractPkScriptAddrs always returns a nil error now, so this should not happen
return nil, nonStandard, fmt.Errorf("ExtractScriptAddrs: %w", err)
}
if nonStandard {
Expand Down
14 changes: 7 additions & 7 deletions dex/networks/btc/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,7 @@ func TestIsDust(t *testing.T) {

func TestExtractScriptAddrs(t *testing.T) {
// Invalid script
_, nonStd, err := ExtractScriptAddrs(invalidScript, tParams)
if err == nil {
t.Fatalf("no error for bad script")
}
_, nonStd, _ := ExtractScriptAddrs(invalidScript, tParams)
if !nonStd {
t.Errorf("expected non-standard script")
}
Expand Down Expand Up @@ -428,9 +425,12 @@ func TestInputInfo(t *testing.T) {
t.Fatalf("no error for missing redeem script")
}
// Redeem script must be parseable.
_, err = InputInfo(script, invalidScript, tParams)
if err == nil {
t.Fatalf("no error for unparseable redeem script")
spendInfo, err = InputInfo(script, invalidScript, tParams)
if err != nil {
t.Fatalf("failed to parse non-standard script")
}
if !spendInfo.NonStandardScript {
t.Errorf("non-standard script was not detected as such")
}
}

Expand Down

0 comments on commit d0d2636

Please sign in to comment.