Merge pull request #4106 from filecoin-project/asr/validate-address
Add an endpoint to validate whether a string is a well-formed address
This commit is contained in:
commit
e250429f56
@ -244,6 +244,8 @@ type FullNode interface {
|
|||||||
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
|
WalletImport(context.Context, *types.KeyInfo) (address.Address, error)
|
||||||
// WalletDelete deletes an address from the wallet.
|
// WalletDelete deletes an address from the wallet.
|
||||||
WalletDelete(context.Context, address.Address) error
|
WalletDelete(context.Context, address.Address) error
|
||||||
|
// WalletValidateAddress validates whether a given string can be decoded as a well-formed address
|
||||||
|
WalletValidateAddress(context.Context, string) (address.Address, error)
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
|
@ -141,6 +141,7 @@ type FullNodeStruct struct {
|
|||||||
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
WalletExport func(context.Context, address.Address) (*types.KeyInfo, error) `perm:"admin"`
|
||||||
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"`
|
||||||
WalletDelete func(context.Context, address.Address) error `perm:"write"`
|
WalletDelete func(context.Context, address.Address) error `perm:"write"`
|
||||||
|
WalletValidateAddress func(context.Context, string) (address.Address, error) `perm:"read"`
|
||||||
|
|
||||||
ClientImport func(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) `perm:"admin"`
|
ClientImport func(ctx context.Context, ref api.FileRef) (*api.ImportRes, error) `perm:"admin"`
|
||||||
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"`
|
||||||
@ -631,6 +632,10 @@ func (c *FullNodeStruct) WalletDelete(ctx context.Context, addr address.Address)
|
|||||||
return c.Internal.WalletDelete(ctx, addr)
|
return c.Internal.WalletDelete(ctx, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) WalletValidateAddress(ctx context.Context, str string) (address.Address, error) {
|
||||||
|
return c.Internal.WalletValidateAddress(ctx, str)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
func (c *FullNodeStruct) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error) {
|
||||||
return c.Internal.MpoolGetNonce(ctx, addr)
|
return c.Internal.MpoolGetNonce(ctx, addr)
|
||||||
}
|
}
|
||||||
|
@ -181,6 +181,7 @@
|
|||||||
* [WalletSetDefault](#WalletSetDefault)
|
* [WalletSetDefault](#WalletSetDefault)
|
||||||
* [WalletSign](#WalletSign)
|
* [WalletSign](#WalletSign)
|
||||||
* [WalletSignMessage](#WalletSignMessage)
|
* [WalletSignMessage](#WalletSignMessage)
|
||||||
|
* [WalletValidateAddress](#WalletValidateAddress)
|
||||||
* [WalletVerify](#WalletVerify)
|
* [WalletVerify](#WalletVerify)
|
||||||
##
|
##
|
||||||
|
|
||||||
@ -4585,6 +4586,21 @@ Response:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### WalletValidateAddress
|
||||||
|
WalletValidateAddress validates whether a given string can be decoded as a well-formed address
|
||||||
|
|
||||||
|
|
||||||
|
Perms: read
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
"string value"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Response: `"t01234"`
|
||||||
|
|
||||||
### WalletVerify
|
### WalletVerify
|
||||||
WalletVerify takes an address, a signature, and some bytes, and indicates whether the signature is valid.
|
WalletVerify takes an address, a signature, and some bytes, and indicates whether the signature is valid.
|
||||||
The address does not have to be in the wallet.
|
The address does not have to be in the wallet.
|
||||||
|
@ -90,3 +90,7 @@ func (a *WalletAPI) WalletImport(ctx context.Context, ki *types.KeyInfo) (addres
|
|||||||
func (a *WalletAPI) WalletDelete(ctx context.Context, addr address.Address) error {
|
func (a *WalletAPI) WalletDelete(ctx context.Context, addr address.Address) error {
|
||||||
return a.Wallet.DeleteKey(addr)
|
return a.Wallet.DeleteKey(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *WalletAPI) WalletValidateAddress(ctx context.Context, str string) (address.Address, error) {
|
||||||
|
return address.NewFromString(str)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user