mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-04 18:13:33 +02:00
multi: repleace ioutil.ReadFile
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
@@ -352,7 +353,7 @@ func printMacaroon(ctx *cli.Context) error {
|
||||
macPath := lncfg.CleanAndExpandPath(ctx.String("macaroon_file"))
|
||||
|
||||
// Load the specified macaroon file.
|
||||
macBytes, err = ioutil.ReadFile(macPath)
|
||||
macBytes, err = os.ReadFile(macPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read macaroon path %v: %v",
|
||||
macPath, err)
|
||||
@@ -441,7 +442,7 @@ func constrainMacaroon(ctx *cli.Context) error {
|
||||
sourceMacFile := lncfg.CleanAndExpandPath(args.First())
|
||||
args = args.Tail()
|
||||
|
||||
sourceMacBytes, err := ioutil.ReadFile(sourceMacFile)
|
||||
sourceMacBytes, err := os.ReadFile(sourceMacFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error trying to read source macaroon file "+
|
||||
"%s: %v", sourceMacFile, err)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -1016,7 +1015,7 @@ func readTerminalOrFile(quit chan struct{}) (string, error) {
|
||||
|
||||
// If it's a path to an existing file and it's small enough, let's try
|
||||
// to read its content now.
|
||||
content, err := ioutil.ReadFile(maybeFile)
|
||||
content, err := os.ReadFile(maybeFile)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -423,7 +422,7 @@ func profileAddMacaroon(ctx *cli.Context) error {
|
||||
|
||||
// Now load and possibly encrypt the macaroon file.
|
||||
macPath := lncfg.CleanAndExpandPath(ctx.GlobalString("macaroonpath"))
|
||||
macBytes, err := ioutil.ReadFile(macPath)
|
||||
macBytes, err := os.ReadFile(macPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read macaroon path: %w", err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -712,7 +711,7 @@ func createWatchOnly(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
jsonFile := lncfg.CleanAndExpandPath(ctx.Args().First())
|
||||
jsonBytes, err := ioutil.ReadFile(jsonFile)
|
||||
jsonBytes, err := os.ReadFile(jsonFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading JSON from file %v: %v",
|
||||
jsonFile, err)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -2833,7 +2832,7 @@ func parseChanBackups(ctx *cli.Context) (*lnrpc.RestoreChanBackupRequest, error)
|
||||
}, nil
|
||||
|
||||
case ctx.IsSet("multi_file"):
|
||||
packedMulti, err := ioutil.ReadFile(ctx.String("multi_file"))
|
||||
packedMulti, err := os.ReadFile(ctx.String("multi_file"))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to decode multi packed "+
|
||||
"backup: %v", err)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@@ -129,7 +130,7 @@ func profileFromContext(ctx *cli.Context, store, skipMacaroons bool) (
|
||||
var tlsCert []byte
|
||||
if tlsCertPath != "" && !insecure {
|
||||
var err error
|
||||
tlsCert, err = ioutil.ReadFile(tlsCertPath)
|
||||
tlsCert, err = os.ReadFile(tlsCertPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not load TLS cert "+
|
||||
"file: %v", err)
|
||||
@@ -167,7 +168,7 @@ func profileFromContext(ctx *cli.Context, store, skipMacaroons bool) (
|
||||
}
|
||||
|
||||
// Now load and possibly encrypt the macaroon file.
|
||||
macBytes, err := ioutil.ReadFile(macPath)
|
||||
macBytes, err := os.ReadFile(macPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read macaroon path (check "+
|
||||
"the network setting!): %v", err)
|
||||
@@ -222,7 +223,7 @@ func loadProfileFile(file string) (*profileFile, error) {
|
||||
return nil, errNoProfileFile
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadFile(file)
|
||||
content, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not load profile file %s: %w",
|
||||
file, err)
|
||||
|
||||
Reference in New Issue
Block a user