diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index 567284298..b6e3b1035 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -56,7 +56,7 @@ type DecodeScriptResult struct { ReqSigs int32 `json:"reqSigs,omitempty"` Type string `json:"type"` Addresses []string `json:"addresses,omitempty"` - P2sh string `json:"p2sh"` + P2sh string `json:"p2sh,omitempty"` } // GetAddedNodeInfoResultAddr models the data of the addresses portion of the diff --git a/rpcserver.go b/rpcserver.go index 8eebe40b1..5ec197762 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -833,7 +833,9 @@ func handleDecodeScript(s *rpcServer, cmd interface{}, closeChan <-chan struct{} ReqSigs: int32(reqSigs), Type: scriptClass.String(), Addresses: addresses, - P2sh: p2sh.EncodeAddress(), + } + if scriptClass != txscript.ScriptHashTy { + reply.P2sh = p2sh.EncodeAddress() } return reply, nil } diff --git a/rpcserverhelp.go b/rpcserverhelp.go index eee0053d9..ad430eb78 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -106,7 +106,7 @@ var helpDescsEnUS = map[string]string{ "decodescriptresult-reqSigs": "The number of required signatures", "decodescriptresult-type": "The type of the script (e.g. 'pubkeyhash')", "decodescriptresult-addresses": "The bitcoin addresses associated with this script", - "decodescriptresult-p2sh": "The script hash for use in pay-to-script-hash transactions", + "decodescriptresult-p2sh": "The script hash for use in pay-to-script-hash transactions (only present if the provided redeem script is not already a pay-to-script-hash script)", // DecodeScriptCmd help. "decodescript--synopsis": "Returns a JSON object with information about the provided hex-encoded script.",