diff --git a/rhp/v4/rpc.go b/rhp/v4/rpc.go index 93d5973..f275c34 100644 --- a/rhp/v4/rpc.go +++ b/rhp/v4/rpc.go @@ -474,11 +474,11 @@ func RPCFundAccounts(ctx context.Context, t TransportClient, cs consensus.State, } // RPCLatestRevision returns the latest revision of a contract. -func RPCLatestRevision(ctx context.Context, t TransportClient, contractID types.FileContractID) (types.V2FileContract, error) { +func RPCLatestRevision(ctx context.Context, t TransportClient, contractID types.FileContractID) (types.V2FileContractRevision, error) { req := rhp4.RPCLatestRevisionRequest{ContractID: contractID} var resp rhp4.RPCLatestRevisionResponse err := callSingleRoundtripRPC(ctx, t, rhp4.RPCLatestRevisionID, &req, &resp) - return resp.Contract, err + return resp.Revision, err } // RPCSectorRoots returns the sector roots for a contract. diff --git a/rhp/v4/server.go b/rhp/v4/server.go index af45916..7cd0543 100644 --- a/rhp/v4/server.go +++ b/rhp/v4/server.go @@ -463,10 +463,19 @@ func (s *Server) handleRPCLatestRevision(stream net.Conn) error { if err != nil { return fmt.Errorf("failed to lock contract: %w", err) } + ci, fce, err := s.contractor.V2FileContractElement(req.ContractID) + if err != nil { + unlock() + return fmt.Errorf("failed to get contract's state element: %w", err) + } unlock() return rhp4.WriteResponse(stream, &rhp4.RPCLatestRevisionResponse{ - Contract: state.Revision, + ChainIndex: ci, + Revision: types.V2FileContractRevision{ + Parent: fce, + Revision: state.Revision, + }, }) }