Correct p2sh field of decodescript RPC result.
The p2sh field in the result should be the encoded address which includes the network (human-readable address) instead of just the raw hash.
This commit is contained in:
parent
92eee5cb96
commit
8a73f9b245
1 changed files with 10 additions and 1 deletions
11
rpcserver.go
11
rpcserver.go
|
@ -741,13 +741,22 @@ func handleDecodeScript(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert the script itself to a pay-to-script-hash address.
|
||||||
|
p2sh, err := btcutil.NewAddressScriptHash(script, net)
|
||||||
|
if err != nil {
|
||||||
|
return nil, btcjson.Error{
|
||||||
|
Code: btcjson.ErrInternal.Code,
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate and return the reply.
|
// Generate and return the reply.
|
||||||
reply := btcjson.DecodeScriptResult{
|
reply := btcjson.DecodeScriptResult{
|
||||||
Asm: disbuf,
|
Asm: disbuf,
|
||||||
ReqSigs: reqSigs,
|
ReqSigs: reqSigs,
|
||||||
Type: scriptType.String(),
|
Type: scriptType.String(),
|
||||||
Addresses: addresses,
|
Addresses: addresses,
|
||||||
P2sh: hex.EncodeToString(btcutil.Hash160(script)),
|
P2sh: p2sh.EncodeAddress(),
|
||||||
}
|
}
|
||||||
return reply, nil
|
return reply, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue