Implement validateaddress.
validateaddress will simply return whether the given address is valid or not. For the full implementation, one should query btcwallet instead.
This commit is contained in:
parent
f439dece37
commit
6f17ebc8cb
1 changed files with 19 additions and 1 deletions
20
rpcserver.go
20
rpcserver.go
|
@ -114,6 +114,7 @@ var rpcHandlersBeforeInit = map[string]commandHandler{
|
|||
"setgenerate": handleSetGenerate,
|
||||
"stop": handleStop,
|
||||
"submitblock": handleSubmitBlock,
|
||||
"validateaddress": handleValidateAddress,
|
||||
"verifychain": handleVerifyChain,
|
||||
}
|
||||
|
||||
|
@ -165,7 +166,6 @@ var rpcAskWallet = map[string]struct{}{
|
|||
"settxfee": struct{}{},
|
||||
"signmessage": struct{}{},
|
||||
"signrawtransaction": struct{}{},
|
||||
"validateaddress": struct{}{},
|
||||
"verifymessage": struct{}{},
|
||||
"walletlock": struct{}{},
|
||||
"walletpassphrase": struct{}{},
|
||||
|
@ -2168,6 +2168,24 @@ func verifyChain(db btcdb.Db, level, depth int32) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// handleValidateAddress implements the validateaddress command.
|
||||
func handleValidateAddress(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (interface{}, error) {
|
||||
c := cmd.(*btcjson.ValidateAddressCmd)
|
||||
|
||||
result := btcjson.ValidateAddressResult{}
|
||||
addr, err := btcutil.DecodeAddress(c.Address, activeNetParams.Params)
|
||||
if err != nil {
|
||||
// Return the default value (false) for IsValid.
|
||||
return result, nil
|
||||
}
|
||||
|
||||
result.Address = addr.EncodeAddress()
|
||||
result.IsValid = true
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// handleVerifyChain implements the verifychain command.
|
||||
func handleVerifyChain(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{}) (interface{}, error) {
|
||||
c := cmd.(*btcjson.VerifyChainCmd)
|
||||
|
||||
|
|
Loading…
Reference in a new issue