internal/prompt: allow compilation in js/wasm environment
The wallet loader has a dependency to the internal/prompt package for prompting the user for certain inputs (e.g. wallet password or new seed). This makes it impossible for projects that use the wallet as a dependency and always provide those inputs as parameters to compile for JavaScript/WebAssembly targets because the prompt code uses some terminal functionality that is not available in JS syscalls. By providing a JS specific implementation that just returns an error we can compile the dependent projects. Adding acutal support for prompting the user in the browser is currently not planned as that can easily be circumvented by providing all inputs as parameters.
This commit is contained in:
parent
36f4c930d7
commit
b5fd915162
2 changed files with 34 additions and 0 deletions
|
@ -2,6 +2,8 @@
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !js
|
||||||
|
|
||||||
package prompt
|
package prompt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
32
internal/prompt/prompt_js.go
Normal file
32
internal/prompt/prompt_js.go
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// Copyright (c) 2015-2021 The btcsuite developers
|
||||||
|
// Use of this source code is governed by an ISC
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package prompt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcwallet/internal/legacy/keystore"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ProvideSeed() ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("prompt not supported in WebAssembly")
|
||||||
|
}
|
||||||
|
|
||||||
|
func ProvidePrivPassphrase() ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("prompt not supported in WebAssembly")
|
||||||
|
}
|
||||||
|
|
||||||
|
func PrivatePass(_ *bufio.Reader, _ *keystore.Store) ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("prompt not supported in WebAssembly")
|
||||||
|
}
|
||||||
|
|
||||||
|
func PublicPass(_ *bufio.Reader, _, _, _ []byte) ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("prompt not supported in WebAssembly")
|
||||||
|
}
|
||||||
|
|
||||||
|
func Seed(_ *bufio.Reader) ([]byte, error) {
|
||||||
|
return nil, fmt.Errorf("prompt not supported in WebAssembly")
|
||||||
|
}
|
Loading…
Reference in a new issue