cmd/chantools: remove use of deprecated ioutil pkg

pull/146/head
Oliver Gugger 3 months ago
parent 3c04692628
commit d3ab662418
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -5,8 +5,8 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"strconv"
"strings"
"time"
@ -133,7 +133,7 @@ func (c *fakeChanBackupCommand) Execute(_ *cobra.Command, _ []string) error {
}
if c.FromChannelGraph != "" {
graphBytes, err := ioutil.ReadFile(c.FromChannelGraph)
graphBytes, err := os.ReadFile(c.FromChannelGraph)
if err != nil {
return fmt.Errorf("error reading graph JSON file %s: "+
"%v", c.FromChannelGraph, err)

@ -7,7 +7,7 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"time"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
@ -230,5 +230,5 @@ func forceCloseChannels(apiURL string, extendedKey *hdkeychain.ExtendedKey,
fileName := fmt.Sprintf("results/forceclose-%s.json",
time.Now().Format("2006-01-02-15-04-05"))
log.Infof("Writing result to %s", fileName)
return ioutil.WriteFile(fileName, summaryBytes, 0644)
return os.WriteFile(fileName, summaryBytes, 0644)
}

@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"regexp"
"time"
@ -204,7 +204,7 @@ func commitPointsFromDB(chanDb *channeldb.ChannelStateDB) ([]*btcec.PublicKey,
}
func commitPointsFromLogFile(lndLog string) ([]*btcec.PublicKey, error) {
logFileBytes, err := ioutil.ReadFile(lndLog)
logFileBytes, err := os.ReadFile(lndLog)
if err != nil {
return nil, fmt.Errorf("error reading log file %s: %w", lndLog,
err)
@ -313,7 +313,7 @@ outer:
fileName := fmt.Sprintf("results/rescueclosed-%s.json",
time.Now().Format("2006-01-02-15-04-05"))
log.Infof("Writing result to %s", fileName)
return ioutil.WriteFile(fileName, summaryBytes, 0644)
return os.WriteFile(fileName, summaryBytes, 0644)
}
func rescueClosedChannel(extendedKey *hdkeychain.ExtendedKey,

@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"os"
"strings"
"time"
@ -299,9 +299,9 @@ func (f *inputFlags) parseInputType() ([]*dataformat.SummaryEntry, error) {
func readInput(input string) ([]byte, error) {
if strings.TrimSpace(input) == "-" {
return ioutil.ReadAll(os.Stdin)
return io.ReadAll(os.Stdin)
}
return ioutil.ReadFile(input)
return os.ReadFile(input)
}
func setupLogging() {

@ -3,7 +3,6 @@ package main
import (
"bytes"
"io"
"io/ioutil"
"os"
"path"
"regexp"
@ -53,14 +52,12 @@ func newHarness(t *testing.T) *harness {
buf := &bytes.Buffer{}
logBackend := btclog.NewBackend(buf)
tempDir, err := ioutil.TempDir("", "chantools")
require.NoError(t, err)
h := &harness{
t: t,
logBuffer: buf,
logger: logBackend.Logger("CHAN"),
tempDir: tempDir,
tempDir: t.TempDir(),
}
h.logger.SetLevel(btclog.LevelTrace)

@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"time"
"github.com/lightninglabs/chantools/btc"
@ -88,5 +88,5 @@ func summarizeChannels(apiURL string,
fileName := fmt.Sprintf("results/summary-%s.json",
time.Now().Format("2006-01-02-15-04-05"))
log.Infof("Writing result to %s", fileName)
return ioutil.WriteFile(fileName, summaryBytes, 0644)
return os.WriteFile(fileName, summaryBytes, 0644)
}

@ -6,7 +6,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"time"
@ -76,7 +75,7 @@ func (c *zombieRecoveryPrepareKeysCommand) Execute(_ *cobra.Command,
return errors.New("invalid payout address, must be P2WPKH")
}
matchFileBytes, err := ioutil.ReadFile(c.MatchFile)
matchFileBytes, err := os.ReadFile(c.MatchFile)
if err != nil {
return fmt.Errorf("error reading match file %s: %w",
c.MatchFile, err)

Loading…
Cancel
Save